Rvest Scraping-为什么这个css / xpath选择器不再工作了?

时间:2017-04-24 19:07:15

标签: html css r web-scraping rvest

建立一个粗刮刀,用于从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)

以下是突出显示投手名称的网站的当前HTML检查: Baseball Reference Pitchers

有人可以让我知道我在这里做错了什么吗?有人可以提出一个解决方案,在这里抓取名称,链接,最终表格吗?

0 个答案:

没有答案