Open JChehe opened 9 years ago
var superagent = require("superagent"); var async = require("async"); var cheerio = require("cheerio"); var url = require("url"); var cnodeUrl = "https://cnodejs.org/"; superagent.get(cnodeUrl) .end(function(err, res){ if(err){ // return next(err); console.log(err); } var $ = cheerio.load(res.text); var urls = []; $(".topic_title").each(function(index, el) { var that = $(el); var absUrl = url.resolve(cnodeUrl, that.attr("href")); urls.push(absUrl); }); console.log("抓取地址数: "+urls.length); var counter = 0; async.mapLimit(urls, 5, function(url, callback){ superagent.get(url) .end(function(err, sres){ var $ = cheerio.load(sres.text); console.log("用户:" + $(".user_name").text() + "的积分:" + $(".big").text()); }); },function(err,result){ console.log(result); }) });
async.mapLimit 不是限制并发数吗? 怎么这里是限制总数的?
async.mapLimit 不是限制并发数吗? 怎么这里是限制总数的?