Soshot/bin/rasterize.js

27 lines
785 B
JavaScript
Raw Normal View History

var page = require('webpage').create(),
address, output;
2013-03-14 11:56:21 +01:00
if (phantom.args.length < 2) {
2013-03-19 17:07:13 +01:00
//console.log('Usage: rasterize.js URL filename');
2013-03-14 11:56:21 +01:00
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
2015-07-10 11:04:56 +02:00
page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0';
page.viewportSize = { width: 1280, height:1024};
2013-03-14 11:56:21 +01:00
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
2013-03-19 17:07:13 +01:00
page.close();
phantom.exit();
2013-03-14 11:56:21 +01:00
} else {
window.setTimeout(function () {
page.render(output);
2013-03-19 17:07:13 +01:00
page.close();
2013-03-14 11:56:21 +01:00
phantom.exit();
}, 1000);
2013-03-14 11:56:21 +01:00
}
});
}