小编Pet*_*goe的帖子

Rvest - UseMethod("read_xml") 中的错误:没有适用于“read_xml”的方法应用于“factor”类的对象

我正在使用以下 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)

r rvest

1
推荐指数
1
解决办法
7444
查看次数

标签 统计

r ×1

rvest ×1