Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
rvest只返回标题_R_Rvest - Fatal编程技术网

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
,您将看到该表确实是空的。内容很可能是动态生成的。