-
Notifications
You must be signed in to change notification settings - Fork 0
/
phantom-map.js
38 lines (35 loc) · 1.31 KB
/
phantom-map.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
var page = require('webpage').create(),
system = require('system'),
origin, dest, steps;
page.viewportSize = {width: 1650, height: 1275};
var url, //'http://54.241.159.188/dwr-lep/index.html'
outfile; //'c:/temp/screenshot.jpg'
if(system.args.length <3){
console.log('no url specified')
phantom.exit(1);
}else{
console.log(system.args.length)
url = system.args[1];
page.open(encodeURI(url),
function (status) {
if (status !== 'success') {
console.log('Unable to access network');
phantom.exit(1)
} else {
page.evaluate(function(){ /* run javascript */})
}
setTimeout(function(){
outfile = system.args[2];
page.render(outfile);
console.log('rendered:', outfile)
phantom.exit();
}, 5000)
});
}
/*
run from cmd with
phantomjs --web-security=true phantom-map.js http://54.241.159.188/dwr-lep/index.html c:\temp\shot.jpg
phantomjs --web-security=true phantom-map.js "http://localhost:3000/terminal?name=Ports America" "c:\temp\ports america.jpg"
phantomjs --web-security=true phantom-map.js http://localhost:3000/terminal?name=nutter c:\temp\nutter.jpg
phantomjs --web-security=true phantom-map.js "http://localhost:3000/terminal?name=howard" "c:\temp\howard.jpg"
*/