【发布时间】:2014-06-13 18:04:55
【问题描述】:
我正在尝试为我自己的工作复制先前答案Scraping html tables into R data frames using the XML package 中使用的方法,但无法获取要提取的数据。我正在使用的网站是: http://www.footballfanalytics.com/articles/football/euro_super_league_table.html
我只想提取每个团队名称及其当前评分的表格。我的代码如下:
library(XML)
theurl <- "http://www.footballfanalytics.com/articles/football/euro_super_league_table.html"
tables <- readHTMLTable(theurl)
n.rows <- unlist(lapply(tables, function(t) dim(t)[1]))
tables[[which.max(n.rows)]]
这会产生错误消息
Error in tables[[which.max(n.rows)]] :
attempt to select less than one element
有人可以提出解决方案吗?这个特定站点中是否有某些东西导致它不起作用?或者有没有更好的替代方法我可以尝试?谢谢
【问题讨论】: