externalCheerioAPI
Hierarchy
- StaticType
- CheerioAPI
Callable
This selector method is the starting point for traversing and manipulating the document. Like jQuery, it's the primary method for selecting elements in the document.
selector
searches within thecontext
scope which searches within theroot
scope.Parameters
externaloptionalselector: S | BasicAcceptedElems<T>
Either a selector to look for within the document, or the contents of a new Cheerio instance.
externaloptionalcontext: null | BasicAcceptedElems<AnyNode>
Either a selector to look for within the root, or the contents of the document to query.
externaloptionalroot: BasicAcceptedElems<Document>
Optional HTML document string.
externaloptionaloptions: CheerioOptions
Returns Cheerio<S extends SelectorType ? Element : T>
Index
Properties
externalfn
Mimic jQuery's prototype alias for plugin authors.
externalload
Type declaration
Parameters
externalcontent: string | Buffer<ArrayBufferLike> | AnyNode | AnyNode[]
externaloptionaloptions: null | CheerioOptions
externaloptionalisDocument: boolean
Returns CheerioAPI
Methods
externalinheritedcontains
Checks to see if the
contained
DOM element is a descendant of thecontainer
DOM element.Parameters
externalcontainer: AnyNode
Potential parent node.
externalcontained: AnyNode
Potential child node.
Returns boolean
Indicates if the nodes contain one another.
externalinheritedhtml
Renders the document.
Parameters
externalthis: CheerioAPI
externaloptionaloptions: CheerioOptions
Options for the renderer.
Returns string
The rendered document.
externalinheritedmerge
$.merge().
Parameters
externalarr1: WritableArrayLike<T>
First array.
externalarr2: ArrayLike<T>
Second array.
Returns ArrayLike<T> | undefined
arr1
, with elements ofarr2
inserted.
externalinheritedparseHTML
Parses a string into an array of DOM nodes. The
context
argument has no meaning for Cheerio, but it is maintained for API compatibility with jQuery.Parameters
externalthis: CheerioAPI
externaldata: string
Markup that will be parsed.
externaloptionalcontext: unknown
Will be ignored. If it is a boolean it will be used as the value of
keepScripts
.externaloptionalkeepScripts: boolean
If false all scripts will be removed.
Returns AnyNode[]
The parsed DOM.
externalinheritedroot
Sometimes you need to work with the top-level root element. To query it, you can use
$.root()
.Parameters
externalthis: CheerioAPI
Returns Cheerio<Document>
Cheerio instance wrapping the root node.
externalinheritedtext
Render the document as text.
This returns the
textContent
of the passed elements. The result will include the contents ofscript
andstype
elements. To avoid this, use.prop('innerText')
instead.Parameters
externalthis: void | CheerioAPI
externaloptionalelements: ArrayLike<AnyNode>
Elements to render.
Returns string
The rendered document.
externalinheritedxml
Render the document as XML.
Parameters
externalthis: CheerioAPI
externaloptionaldom: BasicAcceptedElems<AnyNode>
Element to render.
Returns string
THe rendered document.
A querying function, bound to a document created from the provided markup.
Also provides several helper methods for dealing with the document as a whole.