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

Rvest parse.response 404 error is breaking my for loop. How to keep looping?

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

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

问题是其中一个网址 returns 出现以下错误:

Error in parse.response(r, parser, encoding = encoding) : client error: (404) Not Found

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

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

听起来基础包中的 "try" 函数正是您要找的。