Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何停止url.exists()?_R_Url_Web Scraping_Download_Rcurl - Fatal编程技术网

如何停止url.exists()?

如何停止url.exists()?,r,url,web-scraping,download,rcurl,R,Url,Web Scraping,Download,Rcurl,我有一个PDF URL列表,我想下载这些PDF。但是,并不是所有的url都仍然存在,这就是为什么我以前通过RCurl函数url.exists()检查它们。但是,对于某些URL,此函数将永远运行,而不会产生结果。我甚至不能用withTimeout()函数停止它 我将url.exists()包装到withTimeout(),但超时不起作用: library(RCurl) library(R.utils) url <- "http://www.shangri-la.com/uploadedFil

我有一个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")
库(httr)
URL
库(httr)

url我不使用RCurl包,但根据文档,您应该这样做:
url.exists(url,timeout\u ms=15)
问题似乎是您需要curl中的超时,而不是R中的超时。我正要发布@Roland所说的内容。我只想补充一点,正确的选项是
timeout.ms
(用点而不是下划线)。感谢您的宝贵贡献:)使用timout.ms选项,它可以工作。我不使用RCurl包,但根据文档,您应该这样做:
url.exists(url,timeout\ms=15)
问题似乎是您需要curl内的超时,而不是R内的超时。我们正要发布@Roland所说的内容。我只想补充一点,正确的选项是
timeout.ms
(用点而不是下划线)。感谢您的宝贵贡献:)使用timout.ms选项,它可以工作。
try(length(getBinaryURL(url))>0) == T
http_status(GET(url))
!class(try(GET(url]))) == "try-error"