R - web scraping through multiple URLs? with rvest and purrr

旧城冷巷雨未停 提交于 2019-12-11 16:12:39

问题


I am trying to scrape football(soccer) statistics for a project i'm working on and i'm trying to utilise rvest and purrr to loop through the numeric values at the end of the url. I'm not sure what i'm missing but i have a snippet of the code as well as the error message that keeps coming up.

library(xml2)

library(rvest)

library(purrr) 

wins_URL <- "https://www.premierleague.com/stats/top/clubs/wins?se=%d"

map_df(1:15, function(i){

  cat(".")
  page <- read_html(sprintf(wins_URL, i))

  data.frame(statTable = html_table(html_nodes(page,"td , th")))

}) -> WinsTable

Error in doc_namespaces(doc) : external pointer is not valid

I've only recently started using R so I'm no expert and would just like to know what mistakes I'm making

来源:https://stackoverflow.com/questions/51159150/r-web-scraping-through-multiple-urls-with-rvest-and-purrr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!