【问题标题】:Scrape table using rvest - Embedded symbols/links使用 rvest 刮表 - 嵌入式符号/链接
【发布时间】:2018-04-03 06:08:51
【问题描述】:

我尝试在以下网页上抓取表格:http://www.comstats.de/squad/1-FC+Bayern+München

乍一看,我的方法是成功的,使用以下代码:

read_html("http://www.comstats.de/squad/1-FC+Bayern+München") %>% 
html_node("#inhalt > table.rangliste.autoColor.tablesorter.zoomable") %>%
html_table(header = TRUE, fill = TRUE)

但是,在第二列中,有不同数量的链接符号会导致损坏的表具有不同数量的元素(这就是为什么需要填充 = TRUE)。

我研究了好几个小时...谁能帮帮我?

【问题讨论】:

    标签: html html-table rvest scrape


    【解决方案1】:

    如果有人也在寻找此类问题的答案:一种可能的解决方案是使用包 htmltable (https://cran.r-project.org/web/packages/htmltab/vignettes/htmltab.html):

    library(htmltab)
    
    htmltab(doc = "http://www.comstats.de/squad/1-FC+Bayern+München", which = '//*[@id="inhalt"]/table[2]')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-22
      • 2016-05-16
      • 1970-01-01
      • 2020-11-15
      相关资源
      最近更新 更多