我正在使用以下 rvest 代码:
library(rvest)
URL <- "http://www.soccerstats.com/matches.asp" #Feed page
WS <- read_html (URL) #reads webpage into WS variable
URLs <- WS %>% html_nodes ("a:nth-child(1)") %>% html_attr("href") %>% as.character() # Get the CSS nodes & extract the URLs
URLs <- paste0("http://www.soccerstats.com/",URLs)
grepl("pmatch", oversdf$URLs)
URLs <-subset(oversdf, grepl("pmatch", oversdf$URLs),stringsAsFactors = FALSE)
Catcher1 <- data.frame(FMatch=character(),TotalGoals=character (),stringsAsFactors = FALSE)
#Start of for loop
for (i in URLs) {
WS1 <- read_html(i)
FMatch <- WS1 %>% html_nodes("H1") %>% html_text() %>% as.character()
TotalGoals <- WS1 %>% html_nodes(".trow3+ …Run Code Online (Sandbox Code Playgroud)