@depup/cheerio 1.2.0-depup.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +36 -0
- package/Readme.md +229 -0
- package/changes.json +30 -0
- package/dist/browser/api/attributes.d.ts +385 -0
- package/dist/browser/api/attributes.d.ts.map +1 -0
- package/dist/browser/api/attributes.js +636 -0
- package/dist/browser/api/attributes.js.map +1 -0
- package/dist/browser/api/css.d.ts +42 -0
- package/dist/browser/api/css.d.ts.map +1 -0
- package/dist/browser/api/css.js +116 -0
- package/dist/browser/api/css.js.map +1 -0
- package/dist/browser/api/extract.d.ts +27 -0
- package/dist/browser/api/extract.d.ts.map +1 -0
- package/dist/browser/api/extract.js +42 -0
- package/dist/browser/api/extract.js.map +1 -0
- package/dist/browser/api/forms.d.ts +36 -0
- package/dist/browser/api/forms.d.ts.map +1 -0
- package/dist/browser/api/forms.js +81 -0
- package/dist/browser/api/forms.js.map +1 -0
- package/dist/browser/api/manipulation.d.ts +528 -0
- package/dist/browser/api/manipulation.d.ts.map +1 -0
- package/dist/browser/api/manipulation.js +831 -0
- package/dist/browser/api/manipulation.js.map +1 -0
- package/dist/browser/api/traversing.d.ts +657 -0
- package/dist/browser/api/traversing.d.ts.map +1 -0
- package/dist/browser/api/traversing.js +857 -0
- package/dist/browser/api/traversing.js.map +1 -0
- package/dist/browser/cheerio.d.ts +85 -0
- package/dist/browser/cheerio.d.ts.map +1 -0
- package/dist/browser/cheerio.js +58 -0
- package/dist/browser/cheerio.js.map +1 -0
- package/dist/browser/index-browser.d.mts.map +1 -0
- package/dist/browser/index-browser.mjs.map +1 -0
- package/dist/browser/index.d.ts +5 -0
- package/dist/browser/index.js +3 -0
- package/dist/browser/load-parse.d.ts +20 -0
- package/dist/browser/load-parse.d.ts.map +1 -0
- package/dist/browser/load-parse.js +28 -0
- package/dist/browser/load-parse.js.map +1 -0
- package/dist/browser/load.d.ts +91 -0
- package/dist/browser/load.d.ts.map +1 -0
- package/dist/browser/load.js +129 -0
- package/dist/browser/load.js.map +1 -0
- package/dist/browser/options.d.ts +98 -0
- package/dist/browser/options.d.ts.map +1 -0
- package/dist/browser/options.js +34 -0
- package/dist/browser/options.js.map +1 -0
- package/dist/browser/package.json +3 -0
- package/dist/browser/parse.d.ts +18 -0
- package/dist/browser/parse.d.ts.map +1 -0
- package/dist/browser/parse.js +73 -0
- package/dist/browser/parse.js.map +1 -0
- package/dist/browser/parsers/parse5-adapter.d.ts +20 -0
- package/dist/browser/parsers/parse5-adapter.d.ts.map +1 -0
- package/dist/browser/parsers/parse5-adapter.js +50 -0
- package/dist/browser/parsers/parse5-adapter.js.map +1 -0
- package/dist/browser/slim.d.ts +25 -0
- package/dist/browser/slim.d.ts.map +1 -0
- package/dist/browser/slim.js +22 -0
- package/dist/browser/slim.js.map +1 -0
- package/dist/browser/static.d.ts +112 -0
- package/dist/browser/static.d.ts.map +1 -0
- package/dist/browser/static.js +204 -0
- package/dist/browser/static.js.map +1 -0
- package/dist/browser/types.d.ts +21 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +3 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/browser/utils.d.ts +55 -0
- package/dist/browser/utils.d.ts.map +1 -0
- package/dist/browser/utils.js +84 -0
- package/dist/browser/utils.js.map +1 -0
- package/dist/commonjs/api/attributes.d.ts +385 -0
- package/dist/commonjs/api/attributes.d.ts.map +1 -0
- package/dist/commonjs/api/attributes.js +647 -0
- package/dist/commonjs/api/attributes.js.map +1 -0
- package/dist/commonjs/api/css.d.ts +42 -0
- package/dist/commonjs/api/css.d.ts.map +1 -0
- package/dist/commonjs/api/css.js +119 -0
- package/dist/commonjs/api/css.js.map +1 -0
- package/dist/commonjs/api/extract.d.ts +27 -0
- package/dist/commonjs/api/extract.d.ts.map +1 -0
- package/dist/commonjs/api/extract.js +45 -0
- package/dist/commonjs/api/extract.js.map +1 -0
- package/dist/commonjs/api/forms.d.ts +36 -0
- package/dist/commonjs/api/forms.d.ts.map +1 -0
- package/dist/commonjs/api/forms.js +85 -0
- package/dist/commonjs/api/forms.js.map +1 -0
- package/dist/commonjs/api/manipulation.d.ts +528 -0
- package/dist/commonjs/api/manipulation.d.ts.map +1 -0
- package/dist/commonjs/api/manipulation.js +850 -0
- package/dist/commonjs/api/manipulation.js.map +1 -0
- package/dist/commonjs/api/traversing.d.ts +657 -0
- package/dist/commonjs/api/traversing.d.ts.map +1 -0
- package/dist/commonjs/api/traversing.js +914 -0
- package/dist/commonjs/api/traversing.js.map +1 -0
- package/dist/commonjs/cheerio.d.ts +85 -0
- package/dist/commonjs/cheerio.d.ts.map +1 -0
- package/dist/commonjs/cheerio.js +95 -0
- package/dist/commonjs/cheerio.js.map +1 -0
- package/dist/commonjs/index.d.ts +104 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +250 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/load-parse.d.ts +20 -0
- package/dist/commonjs/load-parse.d.ts.map +1 -0
- package/dist/commonjs/load-parse.js +34 -0
- package/dist/commonjs/load-parse.js.map +1 -0
- package/dist/commonjs/load.d.ts +91 -0
- package/dist/commonjs/load.d.ts.map +1 -0
- package/dist/commonjs/load.js +165 -0
- package/dist/commonjs/load.js.map +1 -0
- package/dist/commonjs/options.d.ts +98 -0
- package/dist/commonjs/options.d.ts.map +1 -0
- package/dist/commonjs/options.js +37 -0
- package/dist/commonjs/options.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parse.d.ts +18 -0
- package/dist/commonjs/parse.d.ts.map +1 -0
- package/dist/commonjs/parse.js +77 -0
- package/dist/commonjs/parse.js.map +1 -0
- package/dist/commonjs/parsers/parse5-adapter.d.ts +20 -0
- package/dist/commonjs/parsers/parse5-adapter.d.ts.map +1 -0
- package/dist/commonjs/parsers/parse5-adapter.js +54 -0
- package/dist/commonjs/parsers/parse5-adapter.js.map +1 -0
- package/dist/commonjs/slim.d.ts +25 -0
- package/dist/commonjs/slim.d.ts.map +1 -0
- package/dist/commonjs/slim.js +30 -0
- package/dist/commonjs/slim.js.map +1 -0
- package/dist/commonjs/static.d.ts +112 -0
- package/dist/commonjs/static.d.ts.map +1 -0
- package/dist/commonjs/static.js +214 -0
- package/dist/commonjs/static.js.map +1 -0
- package/dist/commonjs/types.d.ts +21 -0
- package/dist/commonjs/types.d.ts.map +1 -0
- package/dist/commonjs/types.js +4 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/commonjs/utils.d.ts +55 -0
- package/dist/commonjs/utils.d.ts.map +1 -0
- package/dist/commonjs/utils.js +91 -0
- package/dist/commonjs/utils.js.map +1 -0
- package/dist/esm/api/attributes.d.ts +385 -0
- package/dist/esm/api/attributes.d.ts.map +1 -0
- package/dist/esm/api/attributes.js +636 -0
- package/dist/esm/api/attributes.js.map +1 -0
- package/dist/esm/api/css.d.ts +42 -0
- package/dist/esm/api/css.d.ts.map +1 -0
- package/dist/esm/api/css.js +116 -0
- package/dist/esm/api/css.js.map +1 -0
- package/dist/esm/api/extract.d.ts +27 -0
- package/dist/esm/api/extract.d.ts.map +1 -0
- package/dist/esm/api/extract.js +42 -0
- package/dist/esm/api/extract.js.map +1 -0
- package/dist/esm/api/forms.d.ts +36 -0
- package/dist/esm/api/forms.d.ts.map +1 -0
- package/dist/esm/api/forms.js +81 -0
- package/dist/esm/api/forms.js.map +1 -0
- package/dist/esm/api/manipulation.d.ts +528 -0
- package/dist/esm/api/manipulation.d.ts.map +1 -0
- package/dist/esm/api/manipulation.js +831 -0
- package/dist/esm/api/manipulation.js.map +1 -0
- package/dist/esm/api/traversing.d.ts +657 -0
- package/dist/esm/api/traversing.d.ts.map +1 -0
- package/dist/esm/api/traversing.js +857 -0
- package/dist/esm/api/traversing.js.map +1 -0
- package/dist/esm/cheerio.d.ts +85 -0
- package/dist/esm/cheerio.d.ts.map +1 -0
- package/dist/esm/cheerio.js +58 -0
- package/dist/esm/cheerio.js.map +1 -0
- package/dist/esm/index.d.ts +104 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +202 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/load-parse.d.ts +20 -0
- package/dist/esm/load-parse.d.ts.map +1 -0
- package/dist/esm/load-parse.js +28 -0
- package/dist/esm/load-parse.js.map +1 -0
- package/dist/esm/load.d.ts +91 -0
- package/dist/esm/load.d.ts.map +1 -0
- package/dist/esm/load.js +129 -0
- package/dist/esm/load.js.map +1 -0
- package/dist/esm/options.d.ts +98 -0
- package/dist/esm/options.d.ts.map +1 -0
- package/dist/esm/options.js +34 -0
- package/dist/esm/options.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parse.d.ts +18 -0
- package/dist/esm/parse.d.ts.map +1 -0
- package/dist/esm/parse.js +73 -0
- package/dist/esm/parse.js.map +1 -0
- package/dist/esm/parsers/parse5-adapter.d.ts +20 -0
- package/dist/esm/parsers/parse5-adapter.d.ts.map +1 -0
- package/dist/esm/parsers/parse5-adapter.js +50 -0
- package/dist/esm/parsers/parse5-adapter.js.map +1 -0
- package/dist/esm/slim.d.ts +25 -0
- package/dist/esm/slim.d.ts.map +1 -0
- package/dist/esm/slim.js +22 -0
- package/dist/esm/slim.js.map +1 -0
- package/dist/esm/static.d.ts +112 -0
- package/dist/esm/static.d.ts.map +1 -0
- package/dist/esm/static.js +204 -0
- package/dist/esm/static.js.map +1 -0
- package/dist/esm/types.d.ts +21 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +3 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +55 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/utils.js +84 -0
- package/dist/esm/utils.js.map +1 -0
- package/package.json +219 -0
- package/src/api/attributes.ts +1145 -0
- package/src/api/css.ts +224 -0
- package/src/api/extract.ts +92 -0
- package/src/api/forms.ts +103 -0
- package/src/api/manipulation.ts +1115 -0
- package/src/api/traversing.ts +1175 -0
- package/src/cheerio.ts +143 -0
- package/src/index-browser.mts +10 -0
- package/src/index.ts +294 -0
- package/src/load-parse.ts +39 -0
- package/src/load.ts +282 -0
- package/src/options.ts +136 -0
- package/src/parse.ts +105 -0
- package/src/parsers/parse5-adapter.ts +66 -0
- package/src/slim.ts +33 -0
- package/src/static.ts +312 -0
- package/src/types.ts +58 -0
- package/src/utils.ts +99 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traversing.js","sourceRoot":"","sources":["../../../src/api/traversing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,EAGL,WAAW,EACX,UAAU,GAEX,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,MAAM,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,GACX,MAAM,UAAU,CAAC;AAElB,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAElB,kBAAwD;IAExD,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,QAAQ,GAAG,SAAS,CAAC,kBAAkB,CAAC;YAC5C,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE;YAC9B,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;QAEzB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAE/B,OAAO,IAAI,CAAC,KAAK,CACf,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,E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;;;GAeG;AACH,MAAM,UAAU,OAAO,CAErB,QAAiB;IAEjB,OAAO,IAAI,CAAC,UAAU;QACpB,CAAC,CAAC,IAAI,CAAC,GAAG,CACN,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAC9D;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { InternalOptions } from './options.js';
|
|
2
|
+
import type { AnyNode, Document, ParentNode } from 'domhandler';
|
|
3
|
+
import type { BasicAcceptedElems } from './types.js';
|
|
4
|
+
import * as Attributes from './api/attributes.js';
|
|
5
|
+
import * as Traversing from './api/traversing.js';
|
|
6
|
+
import * as Manipulation from './api/manipulation.js';
|
|
7
|
+
import * as Css from './api/css.js';
|
|
8
|
+
import * as Forms from './api/forms.js';
|
|
9
|
+
import * as Extract from './api/extract.js';
|
|
10
|
+
type MethodsType = typeof Attributes & typeof Traversing & typeof Manipulation & typeof Css & typeof Forms & typeof Extract;
|
|
11
|
+
/**
|
|
12
|
+
* The cheerio class is the central class of the library. It wraps a set of
|
|
13
|
+
* elements and provides an API for traversing, modifying, and interacting with
|
|
14
|
+
* the set.
|
|
15
|
+
*
|
|
16
|
+
* Loading a document will return the Cheerio class bound to the root element of
|
|
17
|
+
* the document. The class will be instantiated when querying the document (when
|
|
18
|
+
* calling `$('selector')`).
|
|
19
|
+
*
|
|
20
|
+
* @example This is the HTML markup we will be using in all of the API examples:
|
|
21
|
+
*
|
|
22
|
+
* ```html
|
|
23
|
+
* <ul id="fruits">
|
|
24
|
+
* <li class="apple">Apple</li>
|
|
25
|
+
* <li class="orange">Orange</li>
|
|
26
|
+
* <li class="pear">Pear</li>
|
|
27
|
+
* </ul>
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare abstract class Cheerio<T> implements ArrayLike<T> {
|
|
31
|
+
length: number;
|
|
32
|
+
[index: number]: T;
|
|
33
|
+
options: InternalOptions;
|
|
34
|
+
/**
|
|
35
|
+
* The root of the document. Can be set by using the `root` argument of the
|
|
36
|
+
* constructor.
|
|
37
|
+
*
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
_root: Cheerio<Document> | null;
|
|
41
|
+
/**
|
|
42
|
+
* Instance of cheerio. Methods are specified in the modules. Usage of this
|
|
43
|
+
* constructor is not recommended. Please use `$.load` instead.
|
|
44
|
+
*
|
|
45
|
+
* @private
|
|
46
|
+
* @param elements - The new selection.
|
|
47
|
+
* @param root - Sets the root node.
|
|
48
|
+
* @param options - Options for the instance.
|
|
49
|
+
*/
|
|
50
|
+
constructor(elements: ArrayLike<T> | undefined, root: Cheerio<Document> | null, options: InternalOptions);
|
|
51
|
+
prevObject: Cheerio<any> | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Make a cheerio object.
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
* @param dom - The contents of the new object.
|
|
57
|
+
* @param context - The context of the new object.
|
|
58
|
+
* @returns The new cheerio object.
|
|
59
|
+
*/
|
|
60
|
+
abstract _make<T>(dom: ArrayLike<T> | T | string, context?: BasicAcceptedElems<AnyNode>): Cheerio<T>;
|
|
61
|
+
/**
|
|
62
|
+
* Parses some content.
|
|
63
|
+
*
|
|
64
|
+
* @private
|
|
65
|
+
* @param content - Content to parse.
|
|
66
|
+
* @param options - Options for parsing.
|
|
67
|
+
* @param isDocument - Allows parser to be switched to fragment mode.
|
|
68
|
+
* @returns A document containing the `content`.
|
|
69
|
+
*/
|
|
70
|
+
abstract _parse(content: string | Document | AnyNode | AnyNode[] | Buffer, options: InternalOptions, isDocument: boolean, context: ParentNode | null): Document;
|
|
71
|
+
/**
|
|
72
|
+
* Render an element or a set of elements.
|
|
73
|
+
*
|
|
74
|
+
* @private
|
|
75
|
+
* @param dom - DOM to render.
|
|
76
|
+
* @returns The rendered DOM.
|
|
77
|
+
*/
|
|
78
|
+
abstract _render(dom: AnyNode | ArrayLike<AnyNode>): string;
|
|
79
|
+
}
|
|
80
|
+
export interface Cheerio<T> extends MethodsType, Iterable<T> {
|
|
81
|
+
cheerio: '[cheerio object]';
|
|
82
|
+
splice: typeof Array.prototype.splice;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=cheerio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cheerio.d.ts","sourceRoot":"","sources":["../../src/cheerio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAE5C,KAAK,WAAW,GAAG,OAAO,UAAU,GAClC,OAAO,UAAU,GACjB,OAAO,YAAY,GACnB,OAAO,GAAG,GACV,OAAO,KAAK,GACZ,OAAO,OAAO,CAAC;AAEjB;;;;;;;;;;;;;;;;;;GAkBG;AACH,8BAAsB,OAAO,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IACtD,MAAM,SAAK;IACX,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;IAEnB,OAAO,EAAE,eAAe,CAAC;IACzB;;;;;OAKG;IACH,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IAEhC;;;;;;;;OAQG;gBAED,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,EAClC,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,IAAI,EAC9B,OAAO,EAAE,eAAe;IAa1B,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACrC;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,CAAC,CAAC,EACd,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,EAC9B,OAAO,CAAC,EAAE,kBAAkB,CAAC,OAAO,CAAC,GACpC,OAAO,CAAC,CAAC,CAAC;IAEb;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,CACb,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,EACzD,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,UAAU,GAAG,IAAI,GACzB,QAAQ;IAEX;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM;CAC5D;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,CAAE,SAAQ,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC1D,OAAO,EAAE,kBAAkB,CAAC;IAE5B,MAAM,EAAE,OAAO,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;CACvC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as Attributes from './api/attributes.js';
|
|
2
|
+
import * as Traversing from './api/traversing.js';
|
|
3
|
+
import * as Manipulation from './api/manipulation.js';
|
|
4
|
+
import * as Css from './api/css.js';
|
|
5
|
+
import * as Forms from './api/forms.js';
|
|
6
|
+
import * as Extract from './api/extract.js';
|
|
7
|
+
/**
|
|
8
|
+
* The cheerio class is the central class of the library. It wraps a set of
|
|
9
|
+
* elements and provides an API for traversing, modifying, and interacting with
|
|
10
|
+
* the set.
|
|
11
|
+
*
|
|
12
|
+
* Loading a document will return the Cheerio class bound to the root element of
|
|
13
|
+
* the document. The class will be instantiated when querying the document (when
|
|
14
|
+
* calling `$('selector')`).
|
|
15
|
+
*
|
|
16
|
+
* @example This is the HTML markup we will be using in all of the API examples:
|
|
17
|
+
*
|
|
18
|
+
* ```html
|
|
19
|
+
* <ul id="fruits">
|
|
20
|
+
* <li class="apple">Apple</li>
|
|
21
|
+
* <li class="orange">Orange</li>
|
|
22
|
+
* <li class="pear">Pear</li>
|
|
23
|
+
* </ul>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export class Cheerio {
|
|
27
|
+
/**
|
|
28
|
+
* Instance of cheerio. Methods are specified in the modules. Usage of this
|
|
29
|
+
* constructor is not recommended. Please use `$.load` instead.
|
|
30
|
+
*
|
|
31
|
+
* @private
|
|
32
|
+
* @param elements - The new selection.
|
|
33
|
+
* @param root - Sets the root node.
|
|
34
|
+
* @param options - Options for the instance.
|
|
35
|
+
*/
|
|
36
|
+
constructor(elements, root, options) {
|
|
37
|
+
this.length = 0;
|
|
38
|
+
this.options = options;
|
|
39
|
+
this._root = root;
|
|
40
|
+
if (elements) {
|
|
41
|
+
for (let idx = 0; idx < elements.length; idx++) {
|
|
42
|
+
this[idx] = elements[idx];
|
|
43
|
+
}
|
|
44
|
+
this.length = elements.length;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Set a signature of the object. */
|
|
49
|
+
Cheerio.prototype.cheerio = '[cheerio object]';
|
|
50
|
+
/*
|
|
51
|
+
* Make cheerio an array-like object
|
|
52
|
+
*/
|
|
53
|
+
Cheerio.prototype.splice = Array.prototype.splice;
|
|
54
|
+
// Support for (const element of $(...)) iteration:
|
|
55
|
+
Cheerio.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
|
|
56
|
+
// Plug in the API
|
|
57
|
+
Object.assign(Cheerio.prototype, Attributes, Traversing, Manipulation, Css, Forms, Extract);
|
|
58
|
+
//# sourceMappingURL=cheerio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cheerio.js","sourceRoot":"","sources":["../../src/cheerio.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAS5C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAgB,OAAO;IAa3B;;;;;;;;OAQG;IACH,YACE,QAAkC,EAClC,IAA8B,EAC9B,OAAwB;QAxB1B,WAAM,GAAG,CAAC,CAAC;QA0BT,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAElB,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;gBAC/C,IAAI,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;QAChC,CAAC;IACH,CAAC;CAwCF;AAQD,qCAAqC;AACrC,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,kBAAkB,CAAC;AAE/C;;GAEG;AACH,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC;AAElD,mDAAmD;AACnD,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAEtE,kBAAkB;AAClB,MAAM,CAAC,MAAM,CACX,OAAO,CAAC,SAAS,EACjB,UAAU,EACV,UAAU,EACV,YAAY,EACZ,GAAG,EACH,KAAK,EACL,OAAO,CACR,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Batteries-included version of Cheerio. This module includes several
|
|
3
|
+
* convenience methods for loading documents from various sources.
|
|
4
|
+
*/
|
|
5
|
+
export * from './load-parse.js';
|
|
6
|
+
export { contains, merge } from './static.js';
|
|
7
|
+
export type * from './types.js';
|
|
8
|
+
export type { Cheerio, CheerioAPI, CheerioOptions, HTMLParser2Options, } from './slim.js';
|
|
9
|
+
import { type SnifferOptions } from 'encoding-sniffer';
|
|
10
|
+
import * as undici from 'undici';
|
|
11
|
+
import { Writable } from 'node:stream';
|
|
12
|
+
import type { CheerioAPI } from './load.js';
|
|
13
|
+
import { type CheerioOptions } from './options.js';
|
|
14
|
+
/**
|
|
15
|
+
* Sniffs the encoding of a buffer, then creates a querying function bound to a
|
|
16
|
+
* document created from the buffer.
|
|
17
|
+
*
|
|
18
|
+
* @category Loading
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* ```js
|
|
22
|
+
* import * as cheerio from 'cheerio';
|
|
23
|
+
*
|
|
24
|
+
* const buffer = fs.readFileSync('index.html');
|
|
25
|
+
* const $ = cheerio.loadBuffer(buffer);
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param buffer - The buffer to sniff the encoding of.
|
|
29
|
+
* @param options - The options to pass to Cheerio.
|
|
30
|
+
* @returns The loaded document.
|
|
31
|
+
*/
|
|
32
|
+
export declare function loadBuffer(buffer: Buffer, options?: DecodeStreamOptions): CheerioAPI;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a stream that parses a sequence of strings into a document.
|
|
35
|
+
*
|
|
36
|
+
* The stream is a `Writable` stream that accepts strings. When the stream is
|
|
37
|
+
* finished, the callback is called with the loaded document.
|
|
38
|
+
*
|
|
39
|
+
* @category Loading
|
|
40
|
+
* @example
|
|
41
|
+
*
|
|
42
|
+
* ```js
|
|
43
|
+
* import * as cheerio from 'cheerio';
|
|
44
|
+
* import * as fs from 'fs';
|
|
45
|
+
*
|
|
46
|
+
* const writeStream = cheerio.stringStream({}, (err, $) => {
|
|
47
|
+
* if (err) {
|
|
48
|
+
* // Handle error
|
|
49
|
+
* }
|
|
50
|
+
*
|
|
51
|
+
* console.log($('h1').text());
|
|
52
|
+
* // Output: Hello, world!
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* fs.createReadStream('my-document.html', { encoding: 'utf8' }).pipe(
|
|
56
|
+
* writeStream,
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @param options - The options to pass to Cheerio.
|
|
61
|
+
* @param cb - The callback to call when the stream is finished.
|
|
62
|
+
* @returns The writable stream.
|
|
63
|
+
*/
|
|
64
|
+
export declare function stringStream(options: CheerioOptions, cb: (err: Error | null | undefined, $: CheerioAPI) => void): Writable;
|
|
65
|
+
export interface DecodeStreamOptions extends CheerioOptions {
|
|
66
|
+
encoding?: SnifferOptions;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Parses a stream of buffers into a document.
|
|
70
|
+
*
|
|
71
|
+
* The stream is a `Writable` stream that accepts buffers. When the stream is
|
|
72
|
+
* finished, the callback is called with the loaded document.
|
|
73
|
+
*
|
|
74
|
+
* @category Loading
|
|
75
|
+
* @param options - The options to pass to Cheerio.
|
|
76
|
+
* @param cb - The callback to call when the stream is finished.
|
|
77
|
+
* @returns The writable stream.
|
|
78
|
+
*/
|
|
79
|
+
export declare function decodeStream(options: DecodeStreamOptions, cb: (err: Error | null | undefined, $: CheerioAPI) => void): Writable;
|
|
80
|
+
type UndiciStreamOptions = Omit<undici.Dispatcher.RequestOptions<unknown>, 'path'>;
|
|
81
|
+
export interface CheerioRequestOptions extends DecodeStreamOptions {
|
|
82
|
+
/** The options passed to `undici`'s `stream` method. */
|
|
83
|
+
requestOptions?: UndiciStreamOptions;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* `fromURL` loads a document from a URL.
|
|
87
|
+
*
|
|
88
|
+
* By default, redirects are allowed and non-2xx responses are rejected.
|
|
89
|
+
*
|
|
90
|
+
* @category Loading
|
|
91
|
+
* @example
|
|
92
|
+
*
|
|
93
|
+
* ```js
|
|
94
|
+
* import * as cheerio from 'cheerio';
|
|
95
|
+
*
|
|
96
|
+
* const $ = await cheerio.fromURL('https://example.com');
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @param url - The URL to load the document from.
|
|
100
|
+
* @param options - The options to pass to Cheerio.
|
|
101
|
+
* @returns The loaded document.
|
|
102
|
+
*/
|
|
103
|
+
export declare function fromURL(url: string | URL, options?: CheerioRequestOptions): Promise<CheerioAPI>;
|
|
104
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC9C,mBAAmB,YAAY,CAAC;AAChC,YAAY,EACV,OAAO,EACP,UAAU,EACV,cAAc,EACd,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAKnB,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,EAAE,QAAQ,EAAY,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAGtB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,UAAU,CAQZ;AA2CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,cAAc,EACvB,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,EAAE,UAAU,KAAK,IAAI,GACzD,QAAQ,CAEV;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB,EAC5B,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,EAAE,CAAC,EAAE,UAAU,KAAK,IAAI,GACzD,QAAQ,CAaV;AAED,KAAK,mBAAmB,GAAG,IAAI,CAC7B,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,EACzC,MAAM,CACP,CAAC;AAEF,MAAM,WAAW,qBAAsB,SAAQ,mBAAmB;IAChE,wDAAwD;IACxD,cAAc,CAAC,EAAE,mBAAmB,CAAC;CACtC;AAUD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,OAAO,CAC3B,GAAG,EAAE,MAAM,GAAG,GAAG,EACjB,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,UAAU,CAAC,CA6ErB"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Batteries-included version of Cheerio. This module includes several
|
|
3
|
+
* convenience methods for loading documents from various sources.
|
|
4
|
+
*/
|
|
5
|
+
export * from './load-parse.js';
|
|
6
|
+
export { contains, merge } from './static.js';
|
|
7
|
+
import { adapter as htmlparser2Adapter } from 'parse5-htmlparser2-tree-adapter';
|
|
8
|
+
import * as htmlparser2 from 'htmlparser2';
|
|
9
|
+
import { ParserStream as Parse5Stream } from 'parse5-parser-stream';
|
|
10
|
+
import { decodeBuffer, DecodeStream, } from 'encoding-sniffer';
|
|
11
|
+
import * as undici from 'undici';
|
|
12
|
+
import MIMEType from 'whatwg-mimetype';
|
|
13
|
+
import { Writable, finished } from 'node:stream';
|
|
14
|
+
import { flattenOptions, } from './options.js';
|
|
15
|
+
import { load } from './load-parse.js';
|
|
16
|
+
/**
|
|
17
|
+
* Sniffs the encoding of a buffer, then creates a querying function bound to a
|
|
18
|
+
* document created from the buffer.
|
|
19
|
+
*
|
|
20
|
+
* @category Loading
|
|
21
|
+
* @example
|
|
22
|
+
*
|
|
23
|
+
* ```js
|
|
24
|
+
* import * as cheerio from 'cheerio';
|
|
25
|
+
*
|
|
26
|
+
* const buffer = fs.readFileSync('index.html');
|
|
27
|
+
* const $ = cheerio.loadBuffer(buffer);
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param buffer - The buffer to sniff the encoding of.
|
|
31
|
+
* @param options - The options to pass to Cheerio.
|
|
32
|
+
* @returns The loaded document.
|
|
33
|
+
*/
|
|
34
|
+
export function loadBuffer(buffer, options = {}) {
|
|
35
|
+
const opts = flattenOptions(options);
|
|
36
|
+
const str = decodeBuffer(buffer, {
|
|
37
|
+
defaultEncoding: (opts === null || opts === void 0 ? void 0 : opts.xmlMode) ? 'utf8' : 'windows-1252',
|
|
38
|
+
...options.encoding,
|
|
39
|
+
});
|
|
40
|
+
return load(str, opts);
|
|
41
|
+
}
|
|
42
|
+
function _stringStream(options, cb) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (options === null || options === void 0 ? void 0 : options._useHtmlParser2) {
|
|
45
|
+
const parser = htmlparser2.createDocumentStream((err, document) => cb(err, load(document, options)), options);
|
|
46
|
+
return new Writable({
|
|
47
|
+
decodeStrings: false,
|
|
48
|
+
write(chunk, _encoding, callback) {
|
|
49
|
+
if (typeof chunk !== 'string') {
|
|
50
|
+
throw new TypeError('Expected a string');
|
|
51
|
+
}
|
|
52
|
+
parser.write(chunk);
|
|
53
|
+
callback();
|
|
54
|
+
},
|
|
55
|
+
final(callback) {
|
|
56
|
+
parser.end();
|
|
57
|
+
callback();
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
options !== null && options !== void 0 ? options : (options = {});
|
|
62
|
+
(_a = options.treeAdapter) !== null && _a !== void 0 ? _a : (options.treeAdapter = htmlparser2Adapter);
|
|
63
|
+
if (options.scriptingEnabled !== false) {
|
|
64
|
+
options.scriptingEnabled = true;
|
|
65
|
+
}
|
|
66
|
+
const stream = new Parse5Stream(options);
|
|
67
|
+
finished(stream, (err) => cb(err, load(stream.document, options)));
|
|
68
|
+
return stream;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates a stream that parses a sequence of strings into a document.
|
|
72
|
+
*
|
|
73
|
+
* The stream is a `Writable` stream that accepts strings. When the stream is
|
|
74
|
+
* finished, the callback is called with the loaded document.
|
|
75
|
+
*
|
|
76
|
+
* @category Loading
|
|
77
|
+
* @example
|
|
78
|
+
*
|
|
79
|
+
* ```js
|
|
80
|
+
* import * as cheerio from 'cheerio';
|
|
81
|
+
* import * as fs from 'fs';
|
|
82
|
+
*
|
|
83
|
+
* const writeStream = cheerio.stringStream({}, (err, $) => {
|
|
84
|
+
* if (err) {
|
|
85
|
+
* // Handle error
|
|
86
|
+
* }
|
|
87
|
+
*
|
|
88
|
+
* console.log($('h1').text());
|
|
89
|
+
* // Output: Hello, world!
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* fs.createReadStream('my-document.html', { encoding: 'utf8' }).pipe(
|
|
93
|
+
* writeStream,
|
|
94
|
+
* );
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @param options - The options to pass to Cheerio.
|
|
98
|
+
* @param cb - The callback to call when the stream is finished.
|
|
99
|
+
* @returns The writable stream.
|
|
100
|
+
*/
|
|
101
|
+
export function stringStream(options, cb) {
|
|
102
|
+
return _stringStream(flattenOptions(options), cb);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Parses a stream of buffers into a document.
|
|
106
|
+
*
|
|
107
|
+
* The stream is a `Writable` stream that accepts buffers. When the stream is
|
|
108
|
+
* finished, the callback is called with the loaded document.
|
|
109
|
+
*
|
|
110
|
+
* @category Loading
|
|
111
|
+
* @param options - The options to pass to Cheerio.
|
|
112
|
+
* @param cb - The callback to call when the stream is finished.
|
|
113
|
+
* @returns The writable stream.
|
|
114
|
+
*/
|
|
115
|
+
export function decodeStream(options, cb) {
|
|
116
|
+
var _a;
|
|
117
|
+
const { encoding = {}, ...cheerioOptions } = options;
|
|
118
|
+
const opts = flattenOptions(cheerioOptions);
|
|
119
|
+
// Set the default encoding to UTF-8 for XML mode
|
|
120
|
+
(_a = encoding.defaultEncoding) !== null && _a !== void 0 ? _a : (encoding.defaultEncoding = (opts === null || opts === void 0 ? void 0 : opts.xmlMode) ? 'utf8' : 'windows-1252');
|
|
121
|
+
const decodeStream = new DecodeStream(encoding);
|
|
122
|
+
const loadStream = _stringStream(opts, cb);
|
|
123
|
+
decodeStream.pipe(loadStream);
|
|
124
|
+
return decodeStream;
|
|
125
|
+
}
|
|
126
|
+
const defaultRequestOptions = {
|
|
127
|
+
method: 'GET',
|
|
128
|
+
// Set an Accept header
|
|
129
|
+
headers: {
|
|
130
|
+
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* `fromURL` loads a document from a URL.
|
|
135
|
+
*
|
|
136
|
+
* By default, redirects are allowed and non-2xx responses are rejected.
|
|
137
|
+
*
|
|
138
|
+
* @category Loading
|
|
139
|
+
* @example
|
|
140
|
+
*
|
|
141
|
+
* ```js
|
|
142
|
+
* import * as cheerio from 'cheerio';
|
|
143
|
+
*
|
|
144
|
+
* const $ = await cheerio.fromURL('https://example.com');
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @param url - The URL to load the document from.
|
|
148
|
+
* @param options - The options to pass to Cheerio.
|
|
149
|
+
* @returns The loaded document.
|
|
150
|
+
*/
|
|
151
|
+
export async function fromURL(url, options = {}) {
|
|
152
|
+
const { requestOptions = defaultRequestOptions, encoding = {}, ...cheerioOptions } = options;
|
|
153
|
+
let undiciStream;
|
|
154
|
+
// Add headers if none were supplied.
|
|
155
|
+
const urlObject = typeof url === 'string' ? new URL(url) : url;
|
|
156
|
+
const streamOptions = {
|
|
157
|
+
headers: defaultRequestOptions.headers,
|
|
158
|
+
path: urlObject.pathname + urlObject.search,
|
|
159
|
+
...requestOptions,
|
|
160
|
+
};
|
|
161
|
+
const promise = new Promise((resolve, reject) => {
|
|
162
|
+
undiciStream = new undici.Client(urlObject.origin)
|
|
163
|
+
.compose(undici.interceptors.redirect({ maxRedirections: 5 }))
|
|
164
|
+
.stream(streamOptions, (res) => {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
167
|
+
throw new undici.errors.ResponseError('Response Error', res.statusCode, {
|
|
168
|
+
headers: res.headers,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
const contentTypeHeader = (_a = res.headers['content-type']) !== null && _a !== void 0 ? _a : 'text/html';
|
|
172
|
+
const mimeType = new MIMEType(Array.isArray(contentTypeHeader)
|
|
173
|
+
? contentTypeHeader[0]
|
|
174
|
+
: contentTypeHeader);
|
|
175
|
+
if (!mimeType.isHTML() && !mimeType.isXML()) {
|
|
176
|
+
throw new RangeError(`The content-type "${mimeType.essence}" is neither HTML nor XML.`);
|
|
177
|
+
}
|
|
178
|
+
// Forward the charset from the header to the decodeStream.
|
|
179
|
+
encoding.transportLayerEncodingLabel =
|
|
180
|
+
mimeType.parameters.get('charset');
|
|
181
|
+
/*
|
|
182
|
+
* If we allow redirects, we will have entries in the history.
|
|
183
|
+
* The last entry will be the final URL.
|
|
184
|
+
*/
|
|
185
|
+
const history = (_b = res.context) === null || _b === void 0 ? void 0 : _b.history;
|
|
186
|
+
// Set the `baseURI` to the final URL.
|
|
187
|
+
const baseURI = history ? history[history.length - 1] : urlObject;
|
|
188
|
+
const opts = {
|
|
189
|
+
encoding,
|
|
190
|
+
// Set XML mode based on the MIME type.
|
|
191
|
+
xmlMode: mimeType.isXML(),
|
|
192
|
+
baseURI,
|
|
193
|
+
...cheerioOptions,
|
|
194
|
+
};
|
|
195
|
+
return decodeStream(opts, (err, $) => (err ? reject(err) : resolve($)));
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
// Let's make sure the request is completed before returning the promise.
|
|
199
|
+
await undiciStream;
|
|
200
|
+
return promise;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAS9C,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,KAAK,WAAW,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,IAAI,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,YAAY,EACZ,YAAY,GAEb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EACL,cAAc,GAGf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,UAAU,CACxB,MAAc,EACd,UAA+B,EAAE;IAEjC,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handler';
|
|
4
|
+
/**
|
|
5
|
+
* Create a querying function, bound to a document created from the provided
|
|
6
|
+
* markup.
|
|
7
|
+
*
|
|
8
|
+
* Note that similar to web browser contexts, this operation may introduce
|
|
9
|
+
* `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
|
|
10
|
+
* switch to fragment mode and disable this.
|
|
11
|
+
*
|
|
12
|
+
* @category Loading
|
|
13
|
+
* @param content - Markup to be loaded.
|
|
14
|
+
* @param options - Options for the created instance.
|
|
15
|
+
* @param isDocument - Allows parser to be switched to fragment mode.
|
|
16
|
+
* @returns The loaded document.
|
|
17
|
+
* @see {@link https://cheerio.js.org/docs/basics/loading#load} for additional usage information.
|
|
18
|
+
*/
|
|
19
|
+
export declare const load: (content: string | AnyNode | AnyNode[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean) => CheerioAPI;
|
|
20
|
+
//# sourceMappingURL=load-parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-parse.d.ts","sourceRoot":"","sources":["../../src/load-parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAW,MAAM,WAAW,CAAC;AAGrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAS1C;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,IAAI,EAAE,CACjB,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,EAC9C,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,EAC/B,UAAU,CAAC,EAAE,OAAO,KACjB,UAIJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getLoad } from './load.js';
|
|
2
|
+
import { getParse } from './parse.js';
|
|
3
|
+
import { renderWithParse5, parseWithParse5 } from './parsers/parse5-adapter.js';
|
|
4
|
+
import renderWithHtmlparser2 from 'dom-serializer';
|
|
5
|
+
import { parseDocument as parseWithHtmlparser2 } from 'htmlparser2';
|
|
6
|
+
const parse = getParse((content, options, isDocument, context) => options._useHtmlParser2
|
|
7
|
+
? parseWithHtmlparser2(content, options)
|
|
8
|
+
: parseWithParse5(content, options, isDocument, context));
|
|
9
|
+
// Duplicate docs due to https://github.com/TypeStrong/typedoc/issues/1616
|
|
10
|
+
/**
|
|
11
|
+
* Create a querying function, bound to a document created from the provided
|
|
12
|
+
* markup.
|
|
13
|
+
*
|
|
14
|
+
* Note that similar to web browser contexts, this operation may introduce
|
|
15
|
+
* `<html>`, `<head>`, and `<body>` elements; set `isDocument` to `false` to
|
|
16
|
+
* switch to fragment mode and disable this.
|
|
17
|
+
*
|
|
18
|
+
* @category Loading
|
|
19
|
+
* @param content - Markup to be loaded.
|
|
20
|
+
* @param options - Options for the created instance.
|
|
21
|
+
* @param isDocument - Allows parser to be switched to fragment mode.
|
|
22
|
+
* @returns The loaded document.
|
|
23
|
+
* @see {@link https://cheerio.js.org/docs/basics/loading#load} for additional usage information.
|
|
24
|
+
*/
|
|
25
|
+
export const load = getLoad(parse, (dom, options) => options._useHtmlParser2
|
|
26
|
+
? renderWithHtmlparser2(dom, options)
|
|
27
|
+
: renderWithParse5(dom));
|
|
28
|
+
//# sourceMappingURL=load-parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-parse.js","sourceRoot":"","sources":["../../src/load-parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,OAAO,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,qBAAqB,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,aAAa,IAAI,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGpE,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAC/D,OAAO,CAAC,eAAe;IACrB,CAAC,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC;IACxC,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAC3D,CAAC;AAEF,0EAA0E;AAC1E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,IAAI,GAIC,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,CAChD,OAAO,CAAC,eAAe;IACrB,CAAC,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC;IACrC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAC1B,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type CheerioOptions, type InternalOptions } from './options.js';
|
|
2
|
+
import * as staticMethods from './static.js';
|
|
3
|
+
import { Cheerio } from './cheerio.js';
|
|
4
|
+
import type { AnyNode, Document, Element } from 'domhandler';
|
|
5
|
+
import type { SelectorType, BasicAcceptedElems } from './types.js';
|
|
6
|
+
type StaticType = typeof staticMethods;
|
|
7
|
+
/**
|
|
8
|
+
* A querying function, bound to a document created from the provided markup.
|
|
9
|
+
*
|
|
10
|
+
* Also provides several helper methods for dealing with the document as a
|
|
11
|
+
* whole.
|
|
12
|
+
*/
|
|
13
|
+
export interface CheerioAPI extends StaticType {
|
|
14
|
+
/**
|
|
15
|
+
* This selector method is the starting point for traversing and manipulating
|
|
16
|
+
* the document. Like jQuery, it's the primary method for selecting elements
|
|
17
|
+
* in the document.
|
|
18
|
+
*
|
|
19
|
+
* `selector` searches within the `context` scope, which searches within the
|
|
20
|
+
* `root` scope.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* ```js
|
|
25
|
+
* $('ul .pear').attr('class');
|
|
26
|
+
* //=> pear
|
|
27
|
+
*
|
|
28
|
+
* $('li[class=orange]').html();
|
|
29
|
+
* //=> Orange
|
|
30
|
+
*
|
|
31
|
+
* $('.apple', '#fruits').text();
|
|
32
|
+
* //=> Apple
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* Optionally, you can also load HTML by passing the string as the selector:
|
|
36
|
+
*
|
|
37
|
+
* ```js
|
|
38
|
+
* $('<ul id="fruits">...</ul>');
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* Or the context:
|
|
42
|
+
*
|
|
43
|
+
* ```js
|
|
44
|
+
* $('ul', '<ul id="fruits">...</ul>');
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* Or as the root:
|
|
48
|
+
*
|
|
49
|
+
* ```js
|
|
50
|
+
* $('li', 'ul', '<ul id="fruits">...</ul>');
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param selector - Either a selector to look for within the document, or the
|
|
54
|
+
* contents of a new Cheerio instance.
|
|
55
|
+
* @param context - Either a selector to look for within the root, or the
|
|
56
|
+
* contents of the document to query.
|
|
57
|
+
* @param root - Optional HTML document string.
|
|
58
|
+
*/
|
|
59
|
+
<T extends AnyNode, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<AnyNode> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<S extends SelectorType ? Element : T>;
|
|
60
|
+
/**
|
|
61
|
+
* The root the document was originally loaded with.
|
|
62
|
+
*
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
_root: Document;
|
|
66
|
+
/**
|
|
67
|
+
* The options the document was originally loaded with.
|
|
68
|
+
*
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
_options: InternalOptions;
|
|
72
|
+
/** Mimic jQuery's prototype alias for plugin authors. */
|
|
73
|
+
fn: typeof Cheerio.prototype;
|
|
74
|
+
/**
|
|
75
|
+
* The `.load` static method defined on the "loaded" Cheerio factory function
|
|
76
|
+
* is deprecated. Users are encouraged to instead use the `load` function
|
|
77
|
+
* exported by the Cheerio module.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Use the `load` function exported by the Cheerio module.
|
|
80
|
+
* @category Deprecated
|
|
81
|
+
* @example
|
|
82
|
+
*
|
|
83
|
+
* ```js
|
|
84
|
+
* const $ = cheerio.load('<h1>Hello, <span>world</span>.</h1>');
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
load: ReturnType<typeof getLoad>;
|
|
88
|
+
}
|
|
89
|
+
export declare function getLoad(parse: Cheerio<AnyNode>['_parse'], render: (dom: AnyNode | ArrayLike<AnyNode>, options: InternalOptions) => string): (content: string | AnyNode | AnyNode[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean) => CheerioAPI;
|
|
90
|
+
export {};
|
|
91
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/load.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EAErB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,aAAa,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAc,MAAM,YAAY,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGnE,KAAK,UAAU,GAAG,OAAO,aAAa,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,UAAW,SAAQ,UAAU;IAC5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;IACH,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,MAAM,EAClC,QAAQ,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CA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