-
Notifications
You must be signed in to change notification settings - Fork 0
/
orangeOdr.js
executable file
·46 lines (38 loc) · 1.02 KB
/
orangeOdr.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
36
37
38
39
40
41
42
43
44
45
46
/**
* Orange ODR
* Labat Guillaume 2013
*/
var accountNumber, casper = require("casper").create({
verbose: false,
logLevel: 'debug'
});
if( casper.cli.args.length === 0 /*&& Object.keys(casper.cli.options).length === 0*/ ) {
casper.echo("Please provide an internet account number").exit();
}
accountNumber = casper.cli.get(0);
casper.start('http://www.suiviodr.orange.fr', function() {
this.withFrame('main', function() {
this.fill('#frm', {
cpt_internet: accountNumber
}, true);
});
});
casper.then(function() {
this.withFrame('main', function() {
this.echo('### ' + new Date().toISOString(), 'INFO');
// Ugly code
this.evaluate(function() {
var elements = __utils__.findAll('div[id^=zone_] div p');
if( !elements || elements.length === 0 ) {
__utils__.echo('No offer');
return;
}
Array.prototype.forEach.call(elements, function(element) {
__utils__.echo(element.innerText);
})
});
});
});
casper.run(function() {
this.exit();
});