Created
July 9, 2012 21:34
-
-
Save jwalsh/3079134 to your computer and use it in GitHub Desktop.
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 page = require('webpage').create(), | |
address, output, size; | |
if (phantom.args.length < 2 || phantom.args.length > 3) { | |
console.log('Usage: ' + phantom.scriptName + ' URL filename'); | |
phantom.exit(); | |
} | |
var start = new Date(); | |
address = phantom.args[0]; | |
output = phantom.args[1]; | |
page.viewportSize = { width: 900, height: 600 }; | |
page.onLoadStarted = function () { | |
var diff = new Date() - start; | |
console.log('Load: start: ' + diff); | |
}; | |
page.onLoadFinished = function (status) { | |
var diff = new Date() - start; | |
console.log('Load: finished: ' + diff); | |
console.log('Page title is ' + page.evaluate( | |
function () { | |
return document.title; | |
})); | |
}; | |
page.open(address, | |
function (status) { | |
console.log('Loading: ' + address); | |
if (status !== 'success') { | |
console.log('Unable to load the address!'); | |
} else { | |
window.setTimeout( | |
function () { | |
console.log('Loaded successfully...'); | |
page.render(output); | |
phantom.exit(); | |
}, 200); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment