1 | /// <reference types="node" />
|
2 | import { CheerioOptions, InternalOptions } from './options';
|
3 | import * as staticMethods from './static';
|
4 | import { Cheerio } from './cheerio';
|
5 | import type { Node, Document, Element } from 'domhandler';
|
6 | import type * as Load from './load';
|
7 | import { SelectorType, BasicAcceptedElems } from './types';
|
8 | declare type StaticType = typeof staticMethods;
|
9 | declare type LoadType = typeof Load;
|
10 | /**
|
11 | * A querying function, bound to a document created from the provided markup.
|
12 | *
|
13 | * Also provides several helper methods for dealing with the document as a whole.
|
14 | */
|
15 | export interface CheerioAPI extends StaticType, LoadType {
|
16 | /**
|
17 | * This selector method is the starting point for traversing and manipulating
|
18 | * the document. Like jQuery, it's the primary method for selecting elements
|
19 | * in the document.
|
20 | *
|
21 | * `selector` searches within the `context` scope which searches within the
|
22 | * `root` scope.
|
23 | *
|
24 | * @example
|
25 | *
|
26 | * ```js
|
27 | * $('.apple', '#fruits').text();
|
28 | * //=> Apple
|
29 | *
|
30 | * $('ul .pear').attr('class');
|
31 | * //=> pear
|
32 | *
|
33 | * $('li[class=orange]').html();
|
34 | * //=> Orange
|
35 | * ```
|
36 | *
|
37 | * @param selector - Either a selector to look for within the document, or the
|
38 | * contents of a new Cheerio instance.
|
39 | * @param context - Either a selector to look for within the root, or the
|
40 | * contents of the document to query.
|
41 | * @param root - Optional HTML document string.
|
42 | */
|
43 | <T extends Node, S extends string>(selector?: S | BasicAcceptedElems<T>, context?: BasicAcceptedElems<Node> | null, root?: BasicAcceptedElems<Document>, options?: CheerioOptions): Cheerio<S extends SelectorType ? Element : T>;
|
44 | /**
|
45 | * The root the document was originally loaded with.
|
46 | *
|
47 | * @private
|
48 | */
|
49 | _root: Document;
|
50 | /**
|
51 | * The options the document was originally loaded with.
|
52 | *
|
53 | * @private
|
54 | */
|
55 | _options: InternalOptions;
|
56 | /** Mimic jQuery's prototype alias for plugin authors. */
|
57 | fn: typeof Cheerio.prototype;
|
58 | }
|
59 | /**
|
60 | * Create a querying function, bound to a document created from the provided
|
61 | * markup. Note that similar to web browser contexts, this operation may
|
62 | * introduce `<html>`, `<head>`, and `<body>` elements; set `isDocument` to
|
63 | * `false` to switch to fragment mode and disable this.
|
64 | *
|
65 | * @param content - Markup to be loaded.
|
66 | * @param options - Options for the created instance.
|
67 | * @param isDocument - Allows parser to be switched to fragment mode.
|
68 | * @returns The loaded document.
|
69 | * @see {@link https://cheerio.js.org#loading} for additional usage information.
|
70 | */
|
71 | export declare function load(content: string | Node | Node[] | Buffer, options?: CheerioOptions | null, isDocument?: boolean): CheerioAPI;
|
72 | export {};
|
73 | //# sourceMappingURL=load.d.ts.map |
\ | No newline at end of file |