【问题标题】:Data Scraping; Extracting links from a table using rvest数据抓取;使用 rvest 从表中提取链接
【发布时间】:2018-11-03 22:21:31
【问题描述】:

我正在尝试从该表中提取所有播放器链接:

https://www.footballdb.com/players/players.html?letter=A

我的代码如下所示:

library(rvest)

url <- "https://www.footballdb.com/players/players.html?letter=A"
webpage <- read_html(url)

webpage %>%
  html_nodes("table") %>%
  html_attr("href")

这将返回一个 NA。我看过其他类似问题的帖子,但我未能很好地理解答案以将它们应用于这个问题。任何解决方案和/或指导将不胜感激。谢谢。

【问题讨论】:

    标签: r web-scraping web-crawler rvest


    【解决方案1】:

    我认为你必须更深入一点;)

    webpage %>%
      html_nodes("table") %>%
      html_nodes("td") %>% 
      html_nodes("a") %>% 
      html_attr("href")
    

    【讨论】:

      猜你喜欢
      • 2019-01-19
      • 1970-01-01
      • 1970-01-01
      • 2015-11-02
      • 2017-10-11
      • 2020-01-30
      • 1970-01-01
      • 2016-05-16
      • 1970-01-01
      相关资源
      最近更新 更多