Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.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
打开连接时出现rvest错误(x,“rb”):已达到超时_R_Rvest - Fatal编程技术网

打开连接时出现rvest错误(x,“rb”):已达到超时

打开连接时出现rvest错误(x,“rb”):已达到超时,r,rvest,R,Rvest,我正试图从中摘取内容。 错误消息出来了 library(rvest) html("http://google.com") 打开连接时出错(x,“rb”): 此外,已达到超时时间: 警告消息:“html”已弃用。 使用“读取html”代替。 请参阅帮助(“已弃用”) 由于我使用的是公司网络,这可能是由防火墙或代理引起的。我尝试使用set_config,但不起作用。这可能是由于您调用read_html(或您的示例中的html)时没有正确地将自己标识到它试图从中检索内容的服务器,这是默认行为。使

我正试图从中摘取内容。 错误消息出来了

library(rvest)  
html("http://google.com")
打开连接时出错(x,“rb”):
此外,已达到超时时间:
警告消息:“html”已弃用。
使用“读取html”代替。
请参阅帮助(“已弃用”)


由于我使用的是公司网络,这可能是由防火墙或代理引起的。我尝试使用set_config,但不起作用。

这可能是由于您调用read_html(或您的示例中的html)时没有正确地将自己标识到它试图从中检索内容的服务器,这是默认行为。使用curl,在read_html的handle参数中添加一个用户代理,以使您的scraper能够识别自己

library(rvest)
library(curl)
read_html(curl('http://google.com', handle = curl::new_handle("useragent" = "Mozilla/5.0")))

我在open.connection(x,“rb”)中遇到了相同的
错误:在办公网络中使用代理时遇到超时问题

这是对我有用的东西

library(rvest)
url = "http://google.com"
download.file(url, destfile = "scrapedpage.html", quiet=TRUE)
content <- read_html("scrapedpage.html")
库(rvest)
url=”http://google.com"
下载.file(url,destfile=“scrapedpage.html”,quiet=TRUE)

内容我遇到了这个问题,因为我的VPN已打开。关闭后,我立即重新尝试,它解决了问题。

我遇到了类似的问题,一个小黑客解决了它。 超链接中有两个角色为我制造了问题。 因此,我将“è”替换为“e”,将“è”替换为“e”,这样做很有效。
但请确保超链接仍然有效。

当我的笔记本电脑通过wifi连接到路由器时,我收到了错误消息,但我的ISP出现了某种中断:

read_html(brand_url)
Error in open.connection(x, "rb") : 
  Timeout was reached: [somewebsite.com.au] Operation timed out after 10024 milliseconds with 0 out of 0 bytes received
在上述情况下,我的wifi仍然连接到调制解调器,但无法通过
rvest
(也不能在浏览器中)加载页面。这是暂时的,持续了约2分钟

还值得注意的是,当wifi完全关闭时,会收到不同的错误消息:

brand_page <- read_html(brand_url)
Error in open.connection(x, "rb") : 
  Could not resolve host: somewebsite.com.au

brand\u页面您是否也尝试了
read\u html
命令,因为错误消息说
html
已被弃用。。。这可能无法解决您的问题,但输出可能更有用…是的,消息是:打开时出错。连接(x,“rb”):超时已达到。此外:警告消息:关闭未使用的连接3()实际上,此代码在我的家庭网络中工作正常。但当我试图在公司网络中使用此代码时,出现了错误。似乎无法作为代码问题重现,这会为我返回一个结果。如果你知道网络发生了什么,以及如何解决这个问题,你可以发布答案。对我来说,同样的问题,显然是从我使用的网络谷歌要求证明自己不是机器人,当然当刮板运行时,页面会超时。这对我来说也很有效。。。在我的例子中,我发现一个更持久的解决方案是设置代理环境变量。以下是步骤:谢谢——这对我来说很有用,使用公司网络。