使用 rvest 抓取 table - 嵌入式 symbols/links

Scrape table using rvest - Embedded symbols/links

我试图在以下网页上抓取 table: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)

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

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

如果有人也在寻找此类问题的答案:一种可能的解决方案是使用包 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]')