我正在从611个网页中提取URL链接。下面的代码可以帮助我下载它们。问题是我遇到以下错误Error in if (grepl("<|>", x)) { : argument is of length zero
,该错误突然停止了该过程,并且没有返回所需的链接列表。如何跳过此错误消息并继续进行数据收集过程?
real.links <- paste0("http://www.bursamalaysia.com" ,links) # if necessary, I can provide the information of the vector 'links'
doc.link <- lapply(real.links, . %>%
read_html() %>% html_nodes("iframe") %>%
html_attr("src") %>% read_html() %>%
html_nodes("a") %>% html_attr("href") %>% print())
# When I inspect "print()", it seems that the function stops at the link 128