[英]Coercing rvest to recognize tables (html_tag(x) == “table” is not TRUE)
I can't seem to ever get html_table()
to work. 我似乎无法让
html_table()
工作。
This is a perfect example: (Trying to scrape the 6 Games: table) 这是一个很好的例子:(试图刮掉6场比赛:桌子)
library(rvest)
hockey <- html("http://www.hockey-reference.com/boxscores/2015/3/6/")
hockey %>%
html_nodes("#stats .tooltip , #stats td , #stats a") %>%
html_table()
But I am getting a html_tag(x) == "table" is not TRUE
. 但是我得到一个
html_tag(x) == "table" is not TRUE
。 It's so obviously a table. 它显然是一张桌子。
How can I coerce rvest to recognize the node as a table? 我怎样才能强迫rvest将节点识别为一个表?
Try either: 尝试:
hockey %>% html_table(fill = TRUE)
to parse all the tables on the page, or 解析页面上的所有表格,或
hockey %>% html_nodes("#stats") %>% html_table()
to parse just the first one you're after. 解析你所追求的第一个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.