var getAllFollowPerson=function(followUrl,cb){ var followArray=[]; request({ url:followUrl, headers:header },function(err,res,body){ var $=cheerio.load(body); var followCount=parseInt($(“.tip2 .tc”)[0].children[0].data.match(/[0-9]+/)[0]); var pageAll=followCount/10+1; pageAll=(pageAll>20?20:pageAll);
for(num=1,i=1;i<=pageAll;i++){
setTimeout(function () {
getFollowPerson(followUrl+"?page="+(num++),followArray);
}, parseInt(Math.random() * 100*followCount));
}
setTimeout(function(){
cb(followArray);
},100*followCount);
});
}