Created
December 13, 2015 10:34
-
-
Save flovv/30a74925958908372e98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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