微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

node-crawler

编程之家收集整理的这个编程导航主要介绍了node-crawler编程之家,现在分享给大家,也给大家做个参考。

node-crawler 介绍

node-crawler这是一个比较好用的node.js爬虫框架,我们可以使用最亲切的jQuery语法来解析响应返回的页面

node-crawler安装

npm install crawler

node-crawler使用

var Crawler = require("crawler");

var c = new Crawler({

maxConnections : 10,

// This will be called for each crawled page

callback : function (error,res,done) {

if(error){

console.log(error);

}else{

var $ = res.$;

// $ is Cheerio by default

//a lean implementation of core jQuery designed specifically for the server

console.log($("title").text());

}

done();

}

});

// Queue just one URL,with default callback

c.queue('http://www.amazon.com');

// Queue a list of URLs

c.queue(['http://www.google.com/','http://www.yahoo.com']);

// Queue URLs with custom callbacks & parameters

c.queue([{

uri: 'http://parishackers.org/',

jQuery: false,

// The global callback won't be called

callback: function (error,done) {

if(error){

console.log(error);

}else{

console.log('Grabbed',res.body.length,'bytes');

}

done();

}

}]);

// Queue some html code directly without grabbing (mostly for tests)

c.queue([{

html: '<p>This is a <strong>test</strong></p>'

}]);

网站地址:http://nodecrawler.org

GitHub:https://github.com/bda-research/node-crawler

网站描述:一款最好的node.js爬虫工具

node-crawler

官方网站:http://nodecrawler.org

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。