我怎样才能停止 url.exists()?

How can I stop url.exists()?

我有一份 PDF URL 列表,我想下载这些 PDF。然而,并不是所有的 URL 仍然存在,这就是为什么我之前通过 RCurl 函数 url.exists() 检查它们的原因。但是,对于某些 URL,此函数将永远 运行 而不会提供结果。我什至不能用 withTimeout() 函数来阻止它。

我把url.exists()包装成withTimeout(),但是超时不起作用:

library(RCurl)
library(R.utils)
url <- "http://www.shangri-la.com/uploadedFiles/corporate/about_us/csr_2011/Shangri-La%20Asia%202010%20Sustainability%20Report.pdf"
withTimeout(url.exists(url), timeout = 15, onTimeout = "warning")

函数永远运行,超时被忽略。

因此我的问题:

我试过的其他检查(但没有解决这个URL)是:

try(length(getBinaryURL(url))>0) == T
http_status(GET(url))
!class(try(GET(url]))) == "try-error"

library(httr)

urls <- c(
  'https://www.deakin.edu.au/current-students/unitguides/UnitGuide.php?year=2015&semester=TRI-1&unit=SLE010', 
  'https://www.deakin.edu.au/current-students/unitguides/UnitGuide.php?year=2015&semester=TRI-2&unit=HMM202',
  'https://www.deakin.edu.au/current-students/unitguides/UnitGuide.php?year=2015&semester=TRI-2&unit=SLE339'
)

sapply(urls, url_success, config(followlocation = 0L), USE.NAMES = FALSE)

此功能类似于 file.exists 并确定对特定 URL 的请求是否正确响应。我们发出请求但要求服务器不要return body。我们只处理 header.