Created
November 6, 2012 11:15
-
-
Save ahomu/4024077 to your computer and use it in GitHub Desktop.
% phantomjs snapshot.js > stdoutfilename
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
var page = require('webpage').create(); | |
var url = 'http://localhost:1234/'; | |
page.viewportSize = { | |
width: 1024, | |
height: 768 | |
}; | |
page.settings.userAgent = 'I am Phantom'; | |
page.open(url, function (a, b, c) { | |
setTimeout(function() { | |
console.log(page.content); | |
phantom.exit(); | |
}, 2000); | |
/* | |
// browser JavaScript call `window.callPhantom` when receive request from PhantomJS | |
if (navigator.userAgent.toUpperCase().indexOf('PHANTOM') !== -1) { | |
window.callPhantom(); | |
} | |
// phantomjs's onCallback | |
page.onCallback = function() { | |
console.log(page.content); | |
phantom.exit(); | |
}; | |
*/ | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also correct?