Reputation: 3
I found this wonderful code on GitHub (https://github.com/rpodcast/nhl_analysis/blob/master/web-scraping/hockey-reference-boxscore-scratch.R), as I am new to R and more familiar to matlab, my goal was just to use the code to get the data I want. I just copied the code from his github, i imported every possible package. After executing the code in RStudio, i get this problem:
table.stats <- readHTMLTable(full.url, header=FALSE) Error: failed to load external entity "http://www.hockey-reference.com/boxscores/199511210BOS.html"
I tried to solve the problem with other Q&A from here, but wasnt able to. I tried to rewrite it using the httr-package instead of the RCurl package, but this doesnt work.
I really appreciate your help.
Upvotes: 0
Views: 36
Reputation: 6116
The codes you're using are last updated 7 years ago. And websites frequently change their HTML design, so codes are not guaranteed to work.
Use the following codes instead.
library(rvest)
library(httr)
ua <- user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36")
url <- 'https://www.hockey-reference.com/boxscores/199511210BOS.html'
session <- html_session(url,ua)
session %>%
html_nodes("table") %>%
html_table()
Upvotes: 0