var page = require('webpage').create(), address, output; if (phantom.args.length < 2) { //console.log('Usage: rasterize.js URL filename'); phantom.exit(); } else { address = phantom.args[0]; output = phantom.args[1]; page.settings.userAgent = 'Mozilla/5.0 (X11; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0'; page.viewportSize = { width: 1280, height:1024}; page.open(address, function (status) { if (status !== 'success') { console.log('Unable to load the address!'); page.close(); phantom.exit(); } else { window.setTimeout(function () { page.render(output); page.close(); phantom.exit(); }, 1000); } }); }