使用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
相关产品推荐
相关产品推荐

