-
-
Save anonymous/f103fa5d4815f1c3a8b3 to your computer and use it in GitHub Desktop.
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 urls = []; | |
var linkedname = []; | |
// var count = ""; | |
$('a').each(function(i, elem) { | |
urls[i] = $(this).attr('href'); | |
console.log(urls[i]); | |
linkedname[i] = $(this).text(); | |
// count = urls.length; | |
if (urls[i].indexOf('http')!=-1) | |
{ | |
urls[i]; | |
} | |
else | |
{ | |
urls[i] = url+urls[i]; | |
} | |
reqi(urls[i], function (error, resp, body) { | |
if (!error && resp.statusCode == 200) { | |
var linkedfilename = linkedname[i] + chance.natural({min: 1, max: 100}); | |
console.log(linkedfilename); | |
fs.writeFile( linkedfilename + '.html', body, function(err){ | |
if(err){ | |
console.log(err); | |
response.end(err); | |
return; | |
} | |
else{ | |
console.log("Again file" + linkedfilename + "written"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment