我正在使用我的 RSelenium 从网络上迭代收集数据。我的代码的示例结构
`for (i in 1:100)
{
re$findElement(using='css', 'some id')$getElementText()
}`
但是当在网页中找不到元素时,它会抛出一个名为 NoSuchElement 的错误。
我想知道一个像这样工作的代码。
for (i in 1:100) { re$findElement(using='css', 'some id')$getElementText() if NoSuchElement is found, break the loop and come out without stopping the program }
我尝试使用 tryCatch,但没有成功。