nodejs的一些依赖库(爬虫用到的几个库)

https://www.npmjs.com/ (以下模块可以在该网站找到对应的api文档)

var superagent = require("superagent"),
    cheerio = require("cheerio"),
    async = require("async"),
    eventproxy = require('eventproxy'),
    mysql = require('mysql'),  //加载mysql数据库模块
    mongoose = require('mongoose'),  //加载mongoose数据库模块
  
    querystring = require("querystring"), //对http请求所带的数据进行解析
    restify = require('restify-clients'), //重新提取的HTTP客户端。
    log4js = require("log4js"), // node 日志管理
    request = require('request'),  //request模块让http请求变的更加简单
    redis = require("redis"),  //redis数据库模块
    download = require('download'),  //下载

mysql

mysql(https://github.com/mysqljs/mysql)
mysql中文版:(http://www.oschina.net/translate/node-mysql-tutorial?utm_source=tuicool&utm_medium=referral)

redis

具体用法在github了解:(https://github.com/NodeRedis/node_redis)

request

具体用法在github了解:(https://github.com/request/request)
还可以在:(http://www.cnblogs.com/meteoric_cry/archive/2012/08/18/2645530.html)

log4js

具体用法在github了解:(https://github.com/nomiddlename/log4js-node)
还可以在:(http://www.cnblogs.com/Joans/p/4092293.html)

querystring

具体用法点开网址:(http://www.cnblogs.com/whiteMu/p/5986297.html)

download

具体用法在github了解:(https://github.com/kevva/download)

restify-clients

具体用法在github了解:(https://github.com/restify/clients)

superagent

superagent(http://visionmedia.github.io/superagent/ ) 是个轻量的的 http 方面的库,是nodejs里一个非常方便的客户端请求代理模块,当我们需要进行 get 、 post 、 head 等网络请求时,尝试下它吧。

cheerio

cheerio(https://github.com/cheeriojs/cheerio ) 大家可以理解成一个 Node.js 版的 jquery,用来从网页中以 css selector 取数据,使用方式跟 jquery 一样一样的。
中文版:(http://cnodejs.org/topic/5203a71844e76d216a727d2e )

eventproxy

eventproxy(https://github.com/JacksonTian/eventproxy ) 非常轻量的工具,但是能够带来一种事件式编程的思维变化。

用 js 写过异步的同学应该都知道,如果你要并发异步获取两三个地址的数据,并且要在获取到数据之后,对这些数据一起进行利用的话,常规的写法是自己维护一个计数器。先定义一个 var count = 0,然后每次抓取成功以后,就 count++。如果你是要抓取三个源的数据,由于你根本不知道这些异步操作到底谁先完成,那么每次当抓取成功的时候,就判断一下count === 3。当值为真时,使用另一个函数继续完成操作。而 eventproxy 就起到了这个计数器的作用,它来帮你管理到底这些异步操作是否完成,完成之后,它会自动调用你提供的处理函数,并将抓取到的(数据当参数传过来)。

async

async(https://github.com/caolan/async#queueworker-concurrency),async是一个流程控制工具包,提供了直接而强大的异步功能mapLimit(arr, limit, iterator, callback)。

这次我们要介绍的是 async 的 mapLimit(arr, limit, iterator, callback) 接口。另外,还有个常用的控制并发连接数的接口是 queue(worker, concurrency) ,大家可以去看看它的API。

你可能感兴趣的:(nodejs的一些依赖库(爬虫用到的几个库))