【问题标题】:Rvest parse.response 404 error is breaking my for loop. How to keep looping?Rvest parse.response 404 错误打破了我的 for 循环。如何保持循环?
【发布时间】:2015-11-07 20:40:11
【问题描述】:

我将以下代码部分嵌套在 for 循环中

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

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

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

这个错误打破了我的for循环,因为页面不存在。

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

【问题讨论】:

    标签: html r web-scraping rvest


    【解决方案1】:

    听起来你正在寻找基本包中的“try”函数。

    【讨论】:

      猜你喜欢
      • 2020-06-15
      • 1970-01-01
      • 1970-01-01
      • 2021-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多