-
Notifications
You must be signed in to change notification settings - Fork 0
/
pa_pres.js
executable file
·32 lines (31 loc) · 1.16 KB
/
pa_pres.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
pjs.config({
// options: 'stdout', 'file' (set in config.logFile) or 'none'
log: 'stdout',
// options: 'json' or 'csv'
format: 'json',
// options: 'stdout' or 'file' (set in config.outFile)
writer: 'file',
outFile: 'pa_pres.json'
});
pjs.addSuite({
url: 'http://www.electionreturns.state.pa.us/ElectionsInformation.aspx?FunctionID=13&ElectionID=53&OfficeID=1'
,scraper: function(){
var tbl = $('#_ctl4_lblText tbody').map(function() {
return $(this).find('td').map(function() {
return $(this).text();
}).get();
}).get();
tbl.splice(0,3);
tbl.splice(24,10);
var results2 = {};
for (i = 0; i < tbl.length / 6; i++){
var s = i*6;
results2[tbl[s]] = {};
results2[tbl[s]]['votes'] = tbl[s+3];
results2[tbl[s]]['percent'] = tbl[s+4];
}
results2['reporting'] = $("font:contains('9,257 Districts')").text();
results2['election'] = 'PA President';
return results2;
}
});