-
-
Save geotheory/9666aba4caed4f723b75ff8ac1418d96 to your computer and use it in GitHub Desktop.
phantom.js script to log all http requests from a page
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(), | |
system = require('system'), | |
address; | |
if (system.args.length === 1) { | |
console.log('Usage: phantomjs url_requests.js http://some.url.com'); | |
phantom.exit(1); | |
} else { | |
address = system.args[1]; | |
var logUrl = function (req) { | |
console.log(req.url); | |
}; | |
page.onResourceRequested = logUrl; | |
page.onResourceReceived = logUrl; | |
page.open(address, function (status) { | |
if (status !== 'success') { | |
console.log('FAIL to load the address'); | |
} | |
phantom.exit(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment