-
Notifications
You must be signed in to change notification settings - Fork 0
/
scraper.js
35 lines (34 loc) · 882 Bytes
/
scraper.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
var nodeio = require('node.io');
exports.job = new nodeio.Job({
auto_retry: true,
timeout: 10,
retries: 1
}, {
input: false,
run: function() {
this.getHtml('https://developer.apple.com/support/system-status/', function(err, $, data, headers) {
if (err) {
this.fail(err);
return;
}
var statuses = [];
$('table.status-table td').each(function(el) {
var status = {};
switch (el.attribs.class) {
case 'online':
var link = $('span a', el);
status.name = link.text;
status.href = link.attribs.href;
status.online = true;
break;
case 'offline':
status.name = $('span', el).text;
status.online = false;
break;
}
statuses.push(status);
});
this.emit(statuses);
});
}
});