Skip to content

Instantly share code, notes, and snippets.

@ygerasimov
Created June 28, 2016 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ygerasimov/782c8608d7e3e7653c1227b3c6b692da to your computer and use it in GitHub Desktop.
Save ygerasimov/782c8608d7e3e7653c1227b3c6b692da to your computer and use it in GitHub Desktop.
var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 4 || phantom.args.length > 5) {
console.log('Usage: viewport.js URL filename sizeX sizeY');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
sizeX = phantom.args[2];
sizeY = phantom.args[3];
page.viewportSize = { width: sizeX, height: sizeY };
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, 200);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment