-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexport.js
51 lines (44 loc) · 1.07 KB
/
export.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
const Fanfou = require('fanfou-sdk');
const async = require('async');
const {
CONSUMER_KEY: consumerKey,
CONSUMER_SECRET: consumerSecret,
FANFOU_USERNAME: username,
FANFOU_PASSWORD: password,
HTTPS: https,
REQUEST_LIMIT: requestLimit
} = require('./config');
const ff = new Fanfou({
consumerKey,
consumerSecret,
username,
password,
protocol: https ? 'https:' : 'http:',
fakeHttps: Boolean(https)
});
(async () => {
await ff.xauth();
const user = await ff.get('/account/verify_credentials');
const {statuses_count: statusesCount} = user;
const pageCount = Math.ceil(statusesCount / 60);
const pages = Array.from({length: pageCount}, (v, i) => i + 1);
let fullList = [];
async.eachLimit(pages, requestLimit, (page, cb) => {
ff.get('/statuses/user_timeline', {page, count: 60, format: 'html'})
.then(list => {
fullList = fullList.concat(list);
cb();
})
.catch(error => {
console.log(error.message);
cb();
});
}, error => {
if (error) {
console.log(error);
} else {
console.log(JSON.stringify(fullList));
}
});
})();