I'm new to node, but I love it already. Only issue is, the asynchronous functionality is killing me.
I am using the google package to get my websites' rankings in google as so:
for (var j=0;j<keywords.length;j++) {
var keyword = keywords[j];
google(keyword, function(err, next, links) {
console.log('Searching for keyword "' + keyword + '" in google.' + google.tld + ' ('+ google.lang +')');
if (err) console.error(err);
for (var i = 0; i < links.length; ++i) {
var rank = i+1;
console.log(keyword + ' #'+ rank + ' - ' + links[i].link + ' | ' + links[i].title);
//link.href is an alias for link.link
//console.log(links[i].description + "
");
}
console.log('
');
});
}
My problem is that it the console log shows the same keyword for all websites, although I have defined three in my keywords array.
What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…