Created
March 20, 2018 10:40
-
-
Save BlackMac/6c131d29874723b3a8dbcb3e9e74931d 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
const http = require("https") | |
const querystring = require('querystring'); | |
var tokens = [] | |
var jsonfile = require('jsonfile') | |
function getin(payload) { | |
var data ={} | |
if (payload) { | |
if (! payload.page_no) { | |
jsonfile.writeFile("out.json", tokens) | |
return | |
} | |
data = { | |
"next_page_payload[page_no]":payload.page_no, | |
"next_page_payload[timestamp]":payload.timestamp, | |
"next_page_payload[direction]":payload.direction | |
} | |
} | |
var url = "https://view.ost.com/chain-id/1409/tokens/top?"+querystring.stringify(data) | |
http.get(url, (res) => { | |
res.setEncoding("utf8"); | |
let body = ""; | |
res.on("data", data => { | |
body += data; | |
}); | |
res.on("end", () => { | |
//sleep(1) | |
body = JSON.parse(body); | |
tokens=tokens.concat(body.data["top_tokens"]) | |
getin(body.data.meta["next_page_payload"]) | |
}); | |
}) | |
} | |
getin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment