Created
December 3, 2013 08:24
-
-
Save yhsiang/7765806 to your computer and use it in GitHub Desktop.
$ phantomjs phantom-angular-runner.js [url]
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
var system = require('system'); | |
var url = system.args[1] || ''; | |
var renderHtml = function(url, cb) { | |
var page = require('webpage').create(); | |
page.settings.loadImages = false; | |
page.settings.localToRemoteUrlAccessEnabled = true; | |
page.onCallback = function() { | |
cb(page.content); | |
page.close(); | |
}; | |
page.onInitialized = function() { | |
page.evaluate(function() { | |
setTimeout(function() { | |
window.callPhantom(); | |
}, 10000); | |
}); | |
}; | |
page.open(url); | |
}; | |
if(url.length > 0) { | |
renderHtml(url, function(html) { | |
console.log(html); | |
phantom.exit(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment