Last active
December 8, 2017 10:38
-
-
Save p410n3/f1356c91ef31c2a551f57c86cedf0381 to your computer and use it in GitHub Desktop.
nodeJS: Find bad HTPP status
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 fetchUrl = require("fetch").fetchUrl; | |
var fs = require('fs'); | |
//Domain list from file | |
var domains = fs.readFileSync('domains.txt').toString().split("\n"); | |
for (i = 0; i < domains.length; i++) { | |
fetchUrl(domains[i], function(error, meta){ | |
//Without the try catch you encounter crashes due to weird async problmes (at least thats my guess) | |
try { | |
if (meta.status == 403 || | |
meta.status == 404 || | |
meta.status == 500 || | |
meta.status == 502 || | |
meta.status == 503 ) { | |
//Outputs only the domains with "bad" Status Codes | |
console.log(meta.finalUrl.toString() + ": "+ meta.status.toString()); | |
} | |
throw 'excpetion'; | |
} | |
catch(e) { | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment