Created
October 9, 2013 13:38
-
-
Save anaynayak/6901447 to your computer and use it in GitHub Desktop.
phantom.js script to log all http requests from a page
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(), | |
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
Use the following to generate unique list of urls accessed from the page:
and
to get a list of unique domains