Skip to content

Instantly share code, notes, and snippets.

@joao
Created May 16, 2015 18:34
Show Gist options
  • Save joao/49242c1b95dbd1c14de1 to your computer and use it in GitHub Desktop.
Save joao/49242c1b95dbd1c14de1 to your computer and use it in GitHub Desktop.
Screenshots with Phantom.js
// SCREENSHOT WEBPAGES WITH PHANTOMJS
// USAGE: phantomjs screenshot.js http://webpage.com screenshot.png
// NOTES: use it in the command line
// WORKS: tested with PhantomJS, installed via Homebrew in OS X
// For passing args in the command line
var system = require('system');
var args = system.args;
// Basic Setup
var page = require('webpage').create();
var url = args[1];
var output_file = args[2];
//Get Page
page.open(url, function() {
// Render and output page
page.render(output_file, {quality: '60'});
// Exit script
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment