Created
March 7, 2013 20:29
-
-
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)
This file contains hidden or 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
| /*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