-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (37 loc) · 1.04 KB
/
index.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
phantom.casperPath = 'node_modules/casperjs';
phantom.injectJs(phantom.casperPath + '/bin/bootstrap.js');
var casper = require('casper').create(
{
waitTimeout:20000
}
);
var url = casper.cli.args[0];
var start = casper.cli.args[1];
var end = casper.cli.args[2];
var h = 595, w = 842, pageArray = [];
for (var i = start; i <= end; i++){
pageArray.push(i);
}
casper.start(
url+'#'+start, function(){
this.echo('starting'); // display the title of page
this.viewport(w, h); // need to set viport here for first page
}
);
casper.then(function() {
this.each(pageArray, function(casper,page) {
this.thenOpen(url+'#'+page, function() {
this.echo(this.getTitle()); // display the title of page
this.viewport(w, h);
})
this.wait(1000, function() { // 1s timeout to allow background image (css) to load... excessive, but works.
this.capture('outputs/'+(page < 10 ? '0' : '')+page+'.png', {
top: 0,
left: 0,
width: w,
height: h
});
});
});
});
casper.run();