Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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