建立一个粗刮刀,用于从Baseball-Reference.com抓取投球统计数据。大约一年前,刮刀可以很好地抓住投手名称和与每个投手相关的链接,但是在最近运行以下代码后,它会返回空的角色向量。
library(rvest)
library(curl)
year = "2017" # Declare a year for looking up stats
appURL <- paste(c("http://www.baseball-reference.com/leagues/MLB/",year,"-standard-pitching.shtml"),collapse = "")
mlbpitcherdata <- read_html(appURL)
mlbpitchers <- mlbpitcherdata %>% html_nodes('#players_standard_pitching_clone > tbody > tr:nth-child(1) > td > a') %>% html_text()
mlbpitcherlinks <- mlbpitcherdata %>% html_nodes('#players_standard_pitching_clone > tbody > tr:nth-child(1) > td > a') %>% html_attr("href")
> mlbpitcherlinks
character(0)
> mlbpitchers
character(0)
有人可以让我知道我在这里做错了什么吗?有人可以提出一个解决方案,在这里抓取名称,链接,最终表格吗?