-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunner.js
32 lines (26 loc) · 804 Bytes
/
runner.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
var page = require('webpage').create(),
system = require('system'),
ss_url = system.args[1],
ss_filename = system.args[2],
ss_width = system.args[3],
ss_height = system.args[4],
ss_time = Date.now();
// Debug
// console.log('Phantom Args:', system.args.join(' '));
if (system.args.length < 5) {
console.log('Usage: runner.js <url> <filename>', system.args);
phantom.exit();
}
page.viewportSize = {
width: ss_width, height: ss_height
};
page.open(ss_url, function (status) {
if (status !== 'success') {
console.error('Failed to load "' + ss_url + '"');
return phantom.exit();
}
page.render(ss_filename);
ss_time = Date.now() - ss_time;
console.log('Captured in ' + ss_time + 'ms (' + ss_filename + ')');
phantom.exit();
});