Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/follow.js
164 views
1
// List following and followers from several accounts
2
3
var users = ['PhantomJS',
4
'ariyahidayat',
5
'detronizator',
6
'KDABQt',
7
'lfranchi',
8
'jonleighton',
9
'_jamesmgreene',
10
'Vitalliumm'];
11
12
function follow(user, callback) {
13
var page = require('webpage').create();
14
page.open('http://mobile.twitter.com/' + user, function (status) {
15
if (status === 'fail') {
16
console.log(user + ': ?');
17
} else {
18
var data = page.evaluate(function () {
19
return document.querySelector('div.profile td.stat.stat-last div.statnum').innerText;
20
});
21
console.log(user + ': ' + data);
22
}
23
page.close();
24
callback.apply();
25
});
26
}
27
28
function process() {
29
if (users.length > 0) {
30
var user = users[0];
31
users.splice(0, 1);
32
follow(user, process);
33
} else {
34
phantom.exit();
35
}
36
}
37
38
process();
39
40