-
Notifications
You must be signed in to change notification settings - Fork 4
/
n2-cheerio.js
28 lines (26 loc) · 986 Bytes
/
n2-cheerio.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
var start = +new Date();
var request = require('request');
var cheerio = require('cheerio');
var total_page = 200;
var page = 1;
var header = ['', 'Rank', 'Team', 'Name', 'Point', 'Total'];
console.log("Page number, Time taken");
while (page <= total_page) {
var url = 'http://fantasy.premierleague.com/my-leagues/303/standings/?ls-page='+page;
request(url, (function(i) {
return function (error, response, body) {
$ = cheerio.load(body);
$('.ismStandingsTable').find('tr').each(function(index, elem){
$(this).find('td').each(function(head){
if (head == 2) {
//console.log(header[head]+ ' : '+$(this).text());
//console.log($(this).text());
}
});
});
var end = +new Date();
console.log(i +", "+(end-start)/1000);
}
})(page)); //bind everything with page number
page++;
}