Optional
selector: S | BasicAcceptedElems<T>Either a selector to look for within the document, or the contents of a new Cheerio instance.
Optional
context: null | BasicAcceptedElems<AnyNode>Either a selector to look for within the root, or the contents of the document to query.
Optional
root: BasicAcceptedElems<Document>Optional HTML document string.
Optional
options: CheerioOptionsPrivate
_optionsThe options the document was originally loaded with.
Private
_rootThe root the document was originally loaded with.
Mimic jQuery's prototype alias for plugin authors.
Optional
options: null | CheerioOptionsRenders the document.
The rendered document.
Optional
options: CheerioOptionsOptions for the renderer.
Renders the document.
The rendered document.
Optional
dom: BasicAcceptedElems<AnyNode>Element to render.
Optional
options: CheerioOptionsOptions for the renderer.
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.
The parsed DOM.
Cheerio.parseHTML
Markup that will be parsed.
Optional
context: unknownWill be ignored. If it is a boolean it will be used as the
value of keepScripts
.
Optional
keepScripts: booleanIf false all scripts will be removed.
Optional
data: null | ""Sometimes you need to work with the top-level root element. To query it, you
can use $.root()
.
$.root().append('<ul id="vegetables"></ul>').html();
//=> <ul id="fruits">...</ul><ul id="vegetables"></ul>
Cheerio instance wrapping the root node.
Cheerio.root
Render the document as text.
This returns the textContent
of the passed elements. The result will
include the contents of script
and stype
elements. To avoid this, use
.prop('innerText')
instead.
The rendered document.
Optional
elements: ArrayLike<AnyNode>Elements to render.
Render the document as XML.
THe rendered document.
Optional
dom: BasicAcceptedElems<AnyNode>Element to render.
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.Example