phantom render script
This commit is contained in:
parent
98667473d8
commit
d9e70e5abd
29
phantom.js
Normal file
29
phantom.js
Normal file
@ -0,0 +1,29 @@
|
||||
var page = require('webpage').create(),
|
||||
system = require('system'),
|
||||
address, output, size;
|
||||
|
||||
var input = system.args[1].split(",");
|
||||
|
||||
address = input[0];
|
||||
output = input[1];
|
||||
var vp_w = input[2];
|
||||
var vp_h = input[3];
|
||||
var js = input[4];
|
||||
|
||||
var pageWidth = (vp_w!="")?parseInt(vp_w, 10):1024;
|
||||
var pageHeight = (vp_h!="")?parseInt(vp_h, 10):'auto';
|
||||
page.viewportSize = { width: pageWidth, height: pageHeight };
|
||||
page.clipRect = { top: 0, left: 0, width: pageWidth, height: pageHeight };
|
||||
page.settings['javascriptEnabled'] = (js=="no")?false:true;
|
||||
|
||||
page.open(address, function (status) {
|
||||
if (status !== 'success') {
|
||||
console.log('Unable to load the address!');
|
||||
phantom.exit(1);
|
||||
} else {
|
||||
window.setTimeout(function () {
|
||||
page.render(output);
|
||||
phantom.exit();
|
||||
}, 200);
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user