一个爬取IP代理地址的小模块,使用了crawler。
const fa = require('fastagency');
//爬取5页IP,间隔为2000毫秒,返回JSON,并保存到本地
fa.update(5,(ips)=>{
console.log(ips);
}
,2000);
//读取本地JSON
fa.getAgency(null,(ips,filePath)=>{
console.log(filePath);
console.log(ips);
});
- 爬取间隔不要太短,会导致爬取不到数据。
- 爬取的数据已经保存在本地,更新IP需要比较长的时间