Created
January 17, 2014 04:47
-
-
Save kumarldh/8468563 to your computer and use it in GitHub Desktop.
loads a page and checks for non secure items.
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 request = require('request'); | |
var cheerio = require('cheerio'); | |
var url = require('url'); | |
var httpsurl = 'https://www.yahoo.com/'; | |
var assets = { | |
img: {src:'src'}, | |
link: {src:'href'}, | |
script: {src:'src'} | |
}; | |
request(httpsurl, function (error, response, html) { | |
if (!error && response.statusCode == 200) { | |
var $ = cheerio.load(html); | |
Object.keys(assets).forEach(function(element) { | |
var attrtolook = assets[element].src; | |
$(element).each(function(i, link){ | |
var parsedurl, elementurl = $(link).attr(attrtolook); | |
if(elementurl !== undefined){ | |
parsedurl = url.parse(elementurl); | |
if(parsedurl.host !== null && parsedurl.protocol !== 'https:'){ | |
console.log(element + ' points to ' + elementurl ); | |
} | |
} | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment