Skip to content

Instantly share code, notes, and snippets.

@flovv
Created December 13, 2015 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flovv/30a74925958908372e98 to your computer and use it in GitHub Desktop.
Save flovv/30a74925958908372e98 to your computer and use it in GitHub Desktop.
require(jsonlite)
require(V8)
#Task: get the Data from the last table: http://www.thebrandticker.com/en/
## public XHR needs a JS time-stamp.
#http://www.thebrandticker.com/ticker.json?1436337115096
#http://www.thebrandticker.com/brands.json?1436337115102
########### just use the JS engine to create a timestamp
ct <- new_context();
strTime = ct$eval("Date.now()")
########## Gather data
str <- paste0("http://www.thebrandticker.com/ticker.json?", strTime)
str2 <- paste0("http://www.thebrandticker.com/brands.json?", strTime)
rd <- readLines(str, warn = "F")
dat <- fromJSON(rd)
df2 <- dat$data
rd2 <- readLines(str2, warn = "F")
dat2 <- fromJSON(rd2)
df3 <- dat2$data
######################## Print to file
out <- rbind(df2, df3)
out$Date <- Sys.Date()
write.csv(out, paste0("data/BrandTicker_", Sys.Date(), ".csv"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment