Created
April 10, 2015 11:42
-
-
Save duncanmorris/69ab9a71b48a2c2897f2 to your computer and use it in GitHub Desktop.
Using PhantomJS to monitor Google Analytics - example 2
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(); | |
var url = 'http://crawlbin.com/response_301/'; | |
console.log('Loading: ' + url); | |
page.onResourceRequested = function (res) { | |
console.log('Requesting: ' + res.url); | |
}; | |
page.open(url, function (status) { | |
//Page is loaded! | |
if (url != page.url){ | |
console.log('Redirected: ' + page.url) | |
} | |
phantom.exit(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
phantomjs example2.js
Output:
Loading: http://crawlbin.com/response_301/
Requesting: http://crawlbin.com/response_301/
Requesting: http://crawlbin.com/
Requesting: https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css
Requesting: http://crawlbin.com/static/crawlbin.css
Requesting: http://crawlbin.com/static/favicon.ico
Redirected: http://crawlbin.com/