Rvest parse.response 404错误打破了我的for循环。如何保持循环?

时间:2015-11-07 20:40:11

标签: html r web-scraping rvest

我将以下代码段嵌套在for循环

mywebsite <- html(webstring)
cast <- html_nodes(mywebsite,".some-node")
text_of_cast<-html_text(cast)

问题是其中一个URL返回以下错误:

  

parse.response(r,parser,encoding = encoding)中的错误:client   错误:(404)未找到

此错误导致我的for循环中断,因为页面不存在。

是否可以忽略此错误并继续循环?

1 个答案:

答案 0 :(得分:1)

听起来&#34;尝试&#34;您正在寻找基础包中的功能。