Created
April 16, 2014 08:13
-
-
Save tsikov/10830153 to your computer and use it in GitHub Desktop.
Сортиране на групи за приятелство по брой депутати.
This file contains hidden or 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
var Crawler = require("crawler").Crawler; | |
var cheerio = require("cheerio"); | |
var c = new Crawler({ | |
"callback": function(error, result) { | |
var fg = []; | |
$ = cheerio.load(result.body); | |
$("ul.DataBlock").find('li').each(function(idx, el) { | |
var ob = { | |
cou: $(el).find('a')[0].children[0].data.split("- ")[1], | |
mem: $(el).find('span')[0].children[0].data.match(/\d+/)[0] | |
} | |
fg.push(ob); | |
}); | |
fg.sort(function(a, b) { return b.mem - a.mem }); | |
fg.forEach(function(ob) { | |
console.log(ob.cou, ob.mem) | |
}); | |
} | |
}); | |
c.queue("http://www.parliament.bg/bg/friendshipgroups"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment