Created
January 13, 2019 13:54
-
-
Save jeroen/81ede584123094eb25a7ea22a0976863 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
parse_streamer <- function(url, cb = print){ | |
con <- curl::curl(url = url) | |
open(con) | |
on.exit(close(con)) | |
repeat{ | |
txt <- readLines(con, 1) | |
if(!length(txt)){ | |
print("All done!") | |
cb(NULL) | |
break; | |
} | |
if(grepl("^data:", txt)){ | |
json <- sub("^data:", "", txt) | |
data <- jsonlite::fromJSON(json) | |
cb(data) | |
} | |
} | |
} | |
parse_streamer('https://mybinder.org/build/gh/karthik/binder-test-fastest/master') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Worked perfectly, thanks!