【发布时间】:2021-06-04 14:29:13
【问题描述】:
我正在运行以下代码:
library(tidyverse)
library(rvest)
library(magrittr)
library(dplyr)
library(tidyr)
library(data.table)
library(zoo)
commits_url <- paste0("https://247sports.com/Season/2022-Football/Commits/?Page=", 1:7)
commits_school_gather <- map_df(commits_url, ~.x %>% read_html %>%
html_nodes('div.status img') %>%
html_attr('title') %>%
matrix(ncol = 1, byrow = T) %>%
as.data.frame)
这应该返回 238 行(至少截至目前,2021 年 3 月 5 日美国东部标准时间下午 5:36。请注意这一点以供将来的文档使用,因为该数字会随着时间而变化)。当我运行代码时,它返回 476 行,这正是我预期的两倍。
如果你运行commits_school_gather %>% head(10),它看起来像这样:
V1
Rutgers
Rutgers
Notre Dame
Notre Dame
Michigan
Michigan
Akron
Akron
Notre Dame
Notre Dame
我希望输出看起来像这样:
V1
Rutgers
Notre Dame
Michigan
Akron
Notre Dame
【问题讨论】: