1
- //! puppeteer-browser-ready v1.2.3 ~~ https://github.com/center-key/puppeteer-browser-ready ~~ MIT License
1
+ //! puppeteer-browser-ready v1.3.0 ~~ https://github.com/center-key/puppeteer-browser-ready ~~ MIT License
2
2
3
3
import { parse } from 'node-html-parser' ;
4
- import cheerio from 'cheerio' ;
5
4
import express from 'express' ;
6
5
import httpTerminator from 'http-terminator' ;
7
6
// Package
@@ -43,10 +42,8 @@ const browserReady = {
43
42
return http . terminator . terminate ( ) ;
44
43
} ,
45
44
goto ( url , options ) {
46
- const defaults = { addCheerio : false , parseHtml : true , verbose : false } ;
45
+ const defaults = { parseHtml : true , verbose : false } ;
47
46
const settings = { ...defaults , ...options } ;
48
- if ( settings . addCheerio )
49
- console . log ( 'puppeteer-browser-ready: Option "addCheerio" is deprecated, use "parseHtml" instead.' ) ;
50
47
const log = ( label , msg ) => settings . verbose &&
51
48
console . log ( ' ' , Date . now ( ) % 100000 , label + ':' , msg ) ;
52
49
const rootInfo = ( root ) => root . constructor . name + '/' + root . firstChild . toString ( ) ;
@@ -65,10 +62,9 @@ const browserReady = {
65
62
log ( 'Title' , title ) ;
66
63
const html = response && await response . text ( ) ;
67
64
log ( 'Bytes' , html ?. length ) ;
68
- const $ = html && settings . addCheerio ? cheerio . load ( html ) : null ; //deprecated
69
65
const root = html && settings . parseHtml ? parse ( html ) : null ;
70
66
log ( 'DOM root' , root ? rootInfo ( root ) : null ) ;
71
- return { browser, page, response, status, location, title, html, $ , root } ;
67
+ return { browser, page, response, status, location, title, html, root } ;
72
68
}
73
69
catch ( error ) {
74
70
const status = browser . isConnected ( ) ? 'connected' : 'not connected' ;
0 commit comments