I can't figure this out and I need some help. Whenever I run my program it will either gather all the correct data, or it won't, or it does but they arrive in a random order. Here is a very simplified version of my code below.
My question is: Am I self taught, am I organizing my code completely wrong?
var request = require('request');
var vFind = 'HelloWorld';
var vGoogle = 'https://www.google.ca';
var vSites = [];
var vFound = false;
request(vGoogle, function (error, response, vBody) {
for (i = 0; i < (vBody.length); i++){
if (vBody.substr(i,vFind.length) == vFind){
vSites = ['http://www.youtube.com','http://www.gmail.com','http://www.apple.com','http://www.live.com','http://www.msn.com','http://www.yahoo.com','http://www.bing.com','http://www.purple.com','http://www.abc.xyz','http://www.reddit.com','http://www.stackoverflow.com','http://www.newgrounds.com','http://www.twitter.com','http://www.flickr.com','http://www.paypal.com','http://www.mediafire.com','http://www.mega.co.nz','http://www.soundcloud.com','http://www.slack.com','http://www.discordapp.com','http://www.trello.com','http://www.ninite.com','http://www.imgur.com','http://www.interacts.js','http://www.drive.google.com'];
break;
}
}
for (j = 0; j < (vSites.length); j++){
request(vSites[j], function (error, response, vBody) {
for (i = 0; i < (vBody.length); i++){
if (vBody.substr(i,vFind.length) == vFind && vFound == false){
vFound = true;
break;
}
}
if (vFound == false)
console.log(vSites[j]+" didn't have it...");
else if (vFound == true){
console.log(vSites[j]+" has it!");
vFound = false;
}
});
}
});
via TheBloodSeeker005
No comments:
Post a Comment