2014-11-23
There are many ways to obtain data from the Internet; let's consider four categories:
Application Programming Interfaces
The API specifies how software components should interact.-wikipedia
There are Thousands of APIs
Why do we want to do this?
gday <- function(team="canucks") { url <- paste0("http://live.nhle.com/GameData/GCScoreboard/", Sys.Date(), ".jsonp") grepl(team, RCurl::getURL(url), ignore.case=TRUE) }
library(httr) req <- GET("http://live.nhle.com/GameData/GCScoreboard/2014-11-24.jsonp") jsonp <- content(req, "text") json <- gsub('([a-zA-Z_0-9\\.]*\\()|(\\);?$)', "", jsonp, perl = TRUE) data <- fromJSON(json) data$games %>% kable