使用类似的代码结构来抓取其他网站。但似乎在访问链接方面存在问题。
用第一行代码解决了网页URL。但是,当我尝试从特定公司站点检索数据时,我收到 SLL 错误。我尝试合并用于网页 URL 的代码,但没有成功。
有解决办法吗?
webpage <- "https://fsncapital.com/en/investments/investments-divestments/"
page <- webpage %>%
httr::GET(config = httr::config(ssl_verifypeer = FALSE)) %>%
read_html()
## Retrieve the embedded linked
Comp_Links = page %>% html_nodes(".investments-grid .name") %>%
html_attr("href")
## get company name
get_ownership =function(comp_link) {
comp_page = read_html(comp_link)
ownership = comp_page %>% html_node("p:nth-child(4)") %>%
html_text()
return(ownership)
}
Ownership = sapply(Comp_Links, FUN = get_ownership)