blob: 049c5bb9afa873cecbd375e53d8dd509a4dc3dae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
var argv = require('minimist')(process.argv.slice(2));
var fetch = require('node-fetch');
var _ = require('lodash');
var url = require('url');
if (typeof argv.u !== "string") {
console.log("username must be specified (-u ugnich)");
return;
}
var messages = [];
function getBlogData(blogUrl, callback) {
fetch(url.format(blogUrl))
.then(function(res) {
return res.json()
})
.then(function(msgs) {
_.each(msgs, function(message) {
messages.push(message);
});
if (msgs.length == 20) {
blog.query.before_mid = msgs.slice(-1).pop().mid;
setTimeout(getBlogData, 1000, blog, callback);
} else {
callback();
}
});
};
var blog = url.parse("https://api.juick.com/messages", true);
blog.query.uname = argv.u;
getBlogData(blog, function() {
console.log(JSON.stringify(messages));
});
|