【问题标题】:Scrape football elo-ratings with rvest用 rvest 刮掉足球 elo 评级
【发布时间】:2018-06-11 21:13:49
【问题描述】:

我正在尝试用rvest 收获world football elo ratings,但我一直得到一个空列表

google chrome 中使用 inspect 元素 我得到 xpath //*[(@id = "maintable_2014_World_Cup_start")]/div[6]

library(rvest)
library(dplyr)

page<-"http://www.eloratings.net/2014_World_Cup_start"

elo_rating<-read_html(page)%>%
   html_nodes(xpath='//[@id="maintable_World"]/div[6]')%>%
   html_table()

我得到一个空列表

在网上和 SE 中搜索,我遇到了this,也许它与 javascript 有关系(我对此一无所知..:)。此外,当在页面源(使用谷歌浏览器)时,我看到很多对 javascript 的调用

最后,我遇到了this R 出版物,其中有一个从同一网站提取数据的示例,但是当我尝试复制 R 代码时,我仍然得到空列表和空字符对象

我在 SE 中经历了很多线程(thisthisthis 但我找不到解决方案

如果障碍是 javascript,我可以做些什么来提取数据?

【问题讨论】:

    标签: r xpath rvest


    【解决方案1】:

    障碍似乎是javascript,因为表格是由它生成的。我认为您需要使用 PhantomJS 来渲染表格并抓取它们。 See this page for help.

    【讨论】:

    • 非常感谢您的提示!非常感谢!会检查出来,让你知道它是怎么回事
    猜你喜欢
    • 2016-03-08
    • 1970-01-01
    • 2014-11-20
    • 2020-04-14
    • 2019-11-18
    • 2022-01-15
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    相关资源
    最近更新 更多