抓取代码如下:
async.each(openids,function(openid,callback){//openid为长度200多的数组
getArcticleNum(openid.openid,function(num){//抓取网页获取特定信息的函数
if(openid.pageNum<num)
{
obj={openid:openid.openid,pageNum:num};
arr.push(obj);
}
callback();
})
},function(err){
db.updateArtNum(arr);
})
})
运行一段时间久开始抓不到数据
抓到数据为:
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
###应该是访问速度过快遭网站屏蔽吧,请问有没有好的方法防止屏蔽? 定时器控制?还是有其他好的方法?
回复 (5)
L
引用 alsotanghttps://github.com/alsotang/node lessons/tree/master/lesson5
@alsotang 确实不错,受教了!
X
L
引用 alsotanghttps://github.com/alsotang/node lessons/tree/master/lesson5
@alsotang 使用async.maplimit() limit设置为1(等同于async.eachseries)在运行几十个之后还是有问题. 有没有执行一个停顿1秒这样的解决方案!
A
引用 lzxue@alsotang 使用async.maplimit() limit设置为1(等同于async.eachseries)在运行几十个之后还是有问题. 有没有执行一个停顿1秒这样的解决方案!
@lzxue 有啊。你在 maplimit 里面,callback 的时候用 settimeout 自己延迟 1s 就好了啊。
参与回复
登录后即可参与回复。登录