Skip to content

Instantly share code, notes, and snippets.

@b-oern
Last active December 15, 2015 15:59
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 b-oern/5285469 to your computer and use it in GitHub Desktop.
Save b-oern/5285469 to your computer and use it in GitHub Desktop.
/**
* Usage:
* phantomjs screenshot.js http://google.de /pi/a.png
*/
var page = require('webpage').create(),
system = require('system');
page.viewportSize = { width: 1280, height: 800 };
if (system.args.length === 1) {
console.log('Usage: screenshot.js <some URL> <Image>');
phantom.exit();
}
var address = system.args[1];
var image = system.args[2];
page.open(address, function (status) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
page.render(image);
}
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment