【发布时间】:2020-12-03 02:47:15
【问题描述】:
我对这种东西有一个非常模板化的东西,我从来没有见过它不起作用。
library(tidyverse)
library(rvest)
library(magrittr)
library(dplyr)
library(tidyr)
library(data.table)
library(zoo)
rivals_url <- paste0("https://rivals.com/prospect_rankings/rivals250/2021")
t300 <- map_df(rivals_url, ~.x %>% read_html %>%
html_nodes(".position .pos , .last-name , .first-name") %>%
html_text() %>%
str_trim %>%
str_split(" ") %>%
matrix(ncol = 3, byrow = T) %>%
as.data.frame)
当我运行它时,它只返回一组空值。是否有一些具体的关于我从哪里拉出来的原因。例如,这个脚本运行良好:
espn_url <- paste0("http://www.espn.com/college-sports/football/recruiting/playerrankings/_/view/rn300")
t300 <- map_df(espn_url, ~.x %>% read_html %>%
html_nodes("td:nth-child(3), td:nth-child(8), Strong, .colhead td:nth-child(2)") %>%
html_text() %>%
str_trim %>%
str_split(" ") %>%
matrix(ncol = 3, byrow = T) %>%
as.data.frame)
【问题讨论】: