rvest只返回标题
下面的代码只返回列标题。我试过几种方法,但都没有成功rvest只返回标题,r,rvest,R,Rvest,下面的代码只返回列标题。我试过几种方法,但都没有成功 library(rvest) the <- read_html("https://www.timeshighereducation.com/world-university-rankings/2018/regional-ranking#!/page/0/length/25/sort_by/rank/sort_order/asc/cols/stats") rating <- the %>% html_nodes("tab
library(rvest)
the <- read_html("https://www.timeshighereducation.com/world-university-rankings/2018/regional-ranking#!/page/0/length/25/sort_by/rank/sort_order/asc/cols/stats")
rating <- the %>%
html_nodes("table") %>%
html_table()
rating
库(rvest)
百分比
html_表()
评级
问题在于表格在页面之前加载。有很多方法可以做到:
在这种情况下,最简单的方法之一是使用RSelenium作为webdriver,并通过以下方式收集结果:
library(RSelenium)
library(rvest)
url <- "https://www.timeshighereducation.com/world-university-rankings/2018/regional-ranking#!/page/0/length/25/sort_by/rank/sort_order/asc/cols/stats"
rD <- rsDriver()
remDr <- rD[["client"]]
remDr$navigate(url)
page <- read_html(remDr$getPageSource()[[1]])
table <- page %>% html_nodes("table") %>% html_table()
table
库(RSelenium)
图书馆(rvest)
url查看读取html(您的url)%%>%html\u文本%>%cat
,您将看到该表确实是空的。内容很可能是动态生成的。