Open yhw60 opened 7 years ago
我需要在外层获取每一页列表的url即topicUrls,然后在获取 详情页中的作者和评论,这种情况下async.mapLimit 限制并发数量不生效了, 貌似导致发起请求过多而阻塞了
试试 async.queue
,搞两层queue
2017-03-19 12:00 GMT+08:00 yanhongwei notifications@github.com:
我需要在外层获取每一页列表的url即topicUrls,然后在获取 详情页中的作者和评论,这种情况下async.mapLimit 限制并发数量不生效了, 貌似导致发起请求过多而阻塞了
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/alsotang/node-lessons/issues/129#issuecomment-287592701, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGB72_ycTOKJrv5yIk-UbYgYEFVJVjGks5rnKhkgaJpZM4Mhn7M .
-- GitHub: https://github.com/alsotang
var util = require('./util/util'); var async = require('async'); var superagent = require('superagent'); var concurrencyCount = 0;
var cnodeUrl = 'https://cnodejs.org/'; var cheerio = require('cheerio');
var stime = new Date();
var fetchUrl = function(url, currentPage) { setTimeout(function () { superagent.get(url).end(function(err, res) { if (err) { // fetchUrl(url,currentPage); return err; }
},200)
}
var allHref = []; var count = 0;