Skip to content

Instantly share code, notes, and snippets.

@booyaa
Created March 7, 2013 20:29
Show Gist options
  • Select an option

  • Save booyaa/5111548 to your computer and use it in GitHub Desktop.

Select an option

Save booyaa/5111548 to your computer and use it in GitHub Desktop.
how to save a webpage (local file or one with a legit uri) in phantomjs (surprised this isn't in the example, may pr and see what happens)
/*jshint phantom: true, laxcomma: true*/
var system = require('system')
,page = require('webpage').create();
if (system.args.length === 1 || system.args.length < 3) {
console.log('Try to pass some args when invoking this script!');
phantom.exit();
}
var url = system.args[1];
var imageFileName = system.args[2];
console.log('opening: ' + url);
page.open(url, function() {
console.log("saving as: " + imageFileName);
page.render(imageFileName);
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment