Detect if a web page has a javascript redirect
Thanks to Ikstar for pointing out phantomjs I worked out the following example:
test.js
var page = require('webpage').create();
var testUrls = [
"http://www.google.nl",
"http://www.example.com"
];
function testNextUrl()
{
var testUrl = testUrls.shift();
page.open(testUrl, function() {
var hasRedirect = page.url.indexOf(testUrl) !== 0;
console.log(testUrl + ": " + hasRedirect.toString());
if (testUrls.length) {
testNextUrl();
} else {
phantom.exit();
}
});
}
testNextUrl();
Result:
D:\Tools\phantomjs-1.7.0-windows>phantomjs test.js
http://www.google.nl: false
http://www.example.com: true