cheerio--不用正则表达式采集网页上的数据
理由:烦正则表达式。
蹊径:解析html为dom树,然后用javascript取回数据。
工具:cheeriojs——"服务端的jQuery"。
示例:
var cheerio = require('cheerio'), $ = cheerio.load('<h2 class = "title">Hello world</h2>'); $('h2.title').text('Hello there!'); $('h2').addClass('welcome'); $.html(); //=> <h2 class = "title welcome">Hello there!</h2>
帮助:
搭配推荐:
superagent _github.io / http
request _github.com / http