You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用rvest爬取PGA Tour数据返回空表,求解决方案建议

PGA Tour网站数据爬取问题求助

我用于爬取数据的PGA Tour网站(链接:https://www.pgatour.com/stats/detail/02675)已更新,目前无法将数据提取为表格格式。我尝试了以下两段rvest代码,但均返回空结果而非表格。我是爬虫新手,恳请各位专家指点:我应继续寻找rvest的其他解决方案,还是转而学习rSelenium这类工具?

多链接爬取代码

library("dplyr")
library("purr")
library("rvest")

df23 <- expand.grid(
  stat_id = c("02568","02674", "02567", "02564", "101")  
) %>% 
  mutate(
    links = paste0(
      'https://www.pgatour.com/stats/detail/',
      stat_id
    )
  ) %>% 
  as_tibble()

#replaced tournament_id with stat_id
get_info <- function(link, stat_id){
  data <- link %>%
    read_html() %>%
    html_table() %>%
    .[[2]] 
}

test_main_stats <- df23 %>%
  mutate(tables = map2(links, stat_id, possibly(get_info, otherwise = tibble())))

test_main_stats <- test_main_stats %>% 
  unnest(everything())

替代代码

url <- read_html("https://www.pgatour.com/stats/detail/02568")
test1 <- url %>%
  html_nodes(".css-8atqhb") %>%
  html_table

内容的提问来源于stack exchange,提问作者DonnyDolio

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 07:10:15