1 | # aimer [![NPM version](https://img.shields.io/npm/v/aimer.svg)](https://npmjs.com/package/aimer) [![NPM downloads](https://img.shields.io/npm/dm/aimer.svg)](https://npmjs.com/package/aimer) [![Circle CI](https://circleci.com/gh/egoist/aimer/tree/master.svg?style=svg)](https://circleci.com/gh/egoist/aimer/tree/master)
|
2 |
|
3 | > Remote web content crawler done right.
|
4 |
|
5 | ## Motivation
|
6 |
|
7 | Sometimes I want grab some nice images from a url like http://bbs.005.tv/thread-492392-1-1.html, so I made this little program to combine `node-fetch` and `cheerio` to make my attempt fulfilled. And it uses `nightmare` to handle SPAs.
|
8 |
|
9 | ## Install
|
10 |
|
11 | ```
|
12 | $ npm install --save aimer
|
13 | ```
|
14 |
|
15 | ## Usage
|
16 |
|
17 | ```js
|
18 | const aimer = require('aimer')
|
19 |
|
20 | aimer('http://some-url.com/a/b/c')
|
21 | .then($ => {
|
22 | $('img.nice-images').each(function () {
|
23 | const url = $(this).attr('src')
|
24 | console.log(url)
|
25 | })
|
26 | })
|
27 |
|
28 | // or even single page website!
|
29 | const nightmare = require('aimer/nightmare')
|
30 | nightmare('http://some-url.com/#!/list')
|
31 | .then($ => {
|
32 | // your code goes here
|
33 | })
|
34 | ```
|
35 |
|
36 | ## API
|
37 |
|
38 | ### aimer(url, opts)
|
39 |
|
40 | #### opts
|
41 |
|
42 | ##### cheerio
|
43 |
|
44 | [cheerio](https://github.com/cheeriojs/cheerio) options. Except `decodeEntities` is `false` by default here.
|
45 |
|
46 | ### nightmare(url, opts)
|
47 |
|
48 | Use [nightmare](https://github.com/segmentio/nightmare) to retrive html from url, this is good for handling with SPA website.
|
49 |
|
50 | #### opts
|
51 |
|
52 | ##### cheerio
|
53 |
|
54 | [cheerio](https://github.com/cheeriojs/cheerio) options. Except `decodeEntities` is `false` by default here.
|
55 |
|
56 | ##### nightmare
|
57 |
|
58 | [nightmare](https://github.com/segmentio/nightmare) options.
|
59 |
|
60 | ## License
|
61 |
|
62 | MIT © [EGOIST](https://github.com/egoist)
|