我有兴趣在网页刮临足球参考。我需要设置一个函数,使我能够刮多个页面。到目前为止,我有代码,似乎是功能。然而,我不断得到一个错误...
scrapeData = function(urlprefix, urlend, startyr, endyr) {
master = data.frame()
for (i in startyr:endyr) {
cat('Loading Year', i, '\n')
URL = paste(urlprefix, as.character(i), urlend, sep = "")
table = readHTMLTable(URL, stringsAsFactors = F)[[1]]
table$Year = i
master = rbind(table, master)
}
return(master)
}
drafts = scrapeData('http://www.pro-football-reference.com/years/', '/draft.htm', 2010, 2010)
当运行它时,返回值是--
Error: failed to load external entity "http://www.pro-football-reference.com/years/2010/draft.htm"
任何建议都很有用。谢谢。
1条答案
按热度按时间kh212irz1#