Thanks to Ikstar for pointing phantomjs I developed 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
sroes
source share