Created
May 16, 2015 18:34
-
-
Save joao/49242c1b95dbd1c14de1 to your computer and use it in GitHub Desktop.
Screenshots with Phantom.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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