首页 > 解决方案 > 网页抓取需要一段时间才能使用 R、rvest、Rslenium 加载的页面

问题描述

我正在尝试网页抓取页面https://sibdatabase.socialfinance.org.uk/并从 class="list" 中获取元素。

问题是,当我尝试使用 rvest 时,页面尚未加载:

library(rvest)
url <- "https://sibdatabase.socialfinance.org.uk/"

url %>%
  read_html() %>% 
  html_nodes(".list")

输出是

{xml_nodeset (0)}

我也尝试了 RSelenium,但发生了错误:

library(RSelenium)

driver <- rsDriver()
remDr <- driver[["client"]]
remDr$navigate("https://sibdatabase.socialfinance.org.uk/")

Could not open chrome browser.
Client error message:
     Summary: SessionNotCreatedException
     Detail: A new session could not be created.
     Further Details: run errorDetails method
Check server log for further details.

标签: rweb-scrapingrvestrselenium

解决方案


推荐阅读