1 | 'use strict'
|
2 | const Nightmare = require('nightmare')
|
3 | const cheerio = require('cheerio')
|
4 | const aimer = require('./')
|
5 |
|
6 | module.exports = function (url, opts) {
|
7 | opts = opts || {}
|
8 |
|
9 | const cheerioOpts = Object.assign({
|
10 |
|
11 | decodeEntities: false
|
12 | }, opts.cheerio)
|
13 |
|
14 | const next = function next() {
|
15 | const nightmare = Nightmare(opts.nightmare)
|
16 | return nightmare.goto(url)
|
17 | .evaluate(() => document.documentElement.outerHTML)
|
18 | .end()
|
19 | .then(res => cheerio.load(res, cheerioOpts))
|
20 | }
|
21 |
|
22 | return aimer(url, {htmlOnly: true}).then(next)
|
23 | }
|