request 简化的HTTP请求的客户端(star:16074)
request被设计成可以进行http调用的最简单的方法。它支持HTTPS,并在默认情况下重定向。
//基本写法,支持promise
request
.get('http://google.com/img.png')
.on('response', function(response) {
console.log(response.statusCode) // 200
console.log(response.headers['content-type']) // 'image/png'
})
.pipe(request.put('http://mysite.com/img.png'))
cheerio 是nodejs的抓取、解析HTML页面模块,为服务器特别定制的,快速、灵活、实施的jQuery核心实现。适合各种Web爬虫程序。(star:12684)
const cheerio = require('cheerio')
const $ = cheerio.load('<h2 class="title">Hello world</h2>')
$('h2.title').text('Hello there!')
$('h2').addClass('welcome')
$.html()
//=> <h2 class="title welcome">Hello there!</h2>
axios基于Promise 的 HTTP 请求客户端,可同时在浏览器和 node.js 中使用。(star:22700)
// Make a request for a user with a given ID
axios.get('/user?ID=12345')
.then(function (response) {
console.log(response);
})
.catch(function (response) {
console.log(response);
});
fetch一个兼容window.fetch特性的polyfill
fetch函数是一个基于promise的用于替代传统浏览器XMLHttpRequest的替代方案(star:14917)
//Usage
fetch('/users.json')
.then(function(response) {
return response.json()
}).then(function(json) {
console.log('parsed json', json)
}).catch(function(ex) {
console.log('parsing failed', ex)
})
jsdom Nodejs抓取、解析HTML网页模块 jsdom(star:7904)
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);
console.log(dom.window.document.querySelector("p").textContent); // "Hello world"
nodemeiler是一个用于Node.js应用邮件发送模块。(star:7966)
'use strict';
const nodemailer = require('nodemailer');
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: 'smtp.example.com',
port: 465,
secure: true, // secure:true for port 465, secure:false for port 587
auth: {
user: 'username@example.com',
pass: 'userpass'
}
});
// setup email data with unicode symbols
let mailOptions = {
from: '"Fred Foo " <foo@blurdybloop.com>', // sender address
to: 'bar@blurdybloop.com, baz@blurdybloop.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world ?', // plain text body
html: '<b>Hello world ?</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
node-schedule是一个基于时间的任务调度器,而不是基于交互,可用来定时执行一个爬虫(star:3672)
node-cron一个基于node的简单定时作业调度器(star:381)
http-server一个简单零配置命令行搭建http服务器的工具(star:5226)
npm install http-server -g
http-server [path] [options]
electron使用javascript、css、html搭建跨平台桌面应用的开源框架,强悍至极!(star:47729)
# Install as a development dependency
npm install electron --save-dev
# Install the `electron` command globally in your $PATH
npm install electron -g
# Clone this repository
git clone https://github.com/electron/electron-quick-start
# Go into the repository
cd electron-quick-start
# Install dependencies
npm install
# Run the app
npm start
node-lru-cache基于node的使用最近最少使用算法的策略进行数据缓存库(star:1416)
npm install lru-cache --save
var LRU = require("lru-cache")
, options = { max: 500
, length: function (n, key) { return n * 2 + key.length }
, dispose: function (key, n) { n.close() }
, maxAge: 1000 * 60 * 60 }
, cache = LRU(options)
, otherCache = LRU(50) // sets just the max size
cache.set("key", "value")
cache.get("key") // "value"
// non-string keys ARE fully supported
var someObject = {}
cache.set(someObject, 'a value')
cache.set('[object Object]', 'a different value')
assert.equal(cache.get(someObject), 'a value')
cache.reset() // empty the cache
es6-promise让es6 promise能兼容更多浏览器,一个polyfill库(star:4677)
npm install es6-promise
var Promise = require('es6-promise').Promise;
Numeral-js用于格式化和操作数字的JavaScript库(star:5214)
nprogress非常漂亮、轻量的页面加载进度条效果
node_redis基于node的redis内存数据库,其中一个策略可用于替代上面的lru cache库(star:8000)