2015-07-09 17:21:32 +02:00
|
|
|
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];
|
2013-05-31 12:28:30 +02:00
|
|
|
page.settings.userAgent = 'SoShot Agent';
|
2015-07-09 17:21:32 +02:00
|
|
|
page.viewportSize = { width: 1280, height:1024};
|
2013-03-14 11:56:21 +01:00
|
|
|
|
|
|
|
page.open(address, function (status) {
|
|
|
|
if (status !== 'success') {
|
2013-03-19 17:07:13 +01:00
|
|
|
//console.log('Unable to load the address!');
|
|
|
|
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();
|
2013-03-26 15:23:02 +01:00
|
|
|
}, 300);
|
2013-03-14 11:56:21 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|