-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (28 loc) · 959 Bytes
/
index.js
File metadata and controls
35 lines (28 loc) · 959 Bytes
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
Crawler = require("crawler");
var url = require('url'),
fs = require('fs');
var c = new Crawler({
maxConnections : 10,
// This will be called for each crawled page
callback : function (error, result, $) {
// $ is Cheerio by default
//a lean implementation of core jQuery designed specifically for the server
$('a').each(function(index, a) {
var toQueueUrl = $(a).attr('href');
c.queue(toQueueUrl);
});
}
});
c.queue([{
uri: 'http://minhaclaro.claro.com.br/portal/site/MinhaClaro/RedirectBL/ConsultaConsumo',
jQuery: true,
// The global callback won't be called
callback: function (error, result, $) {
var textConteudo = $('#conteudo').text() + ' --------- ';
fs = require('fs');
fs.writeFile('claroConsumo.txt', textConteudo, function (err) {
if (err) return console.log(err);
});
//console.log('Grabbed', textConteudo, 'bytes');
}
}]);