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.
The .load
static method defined on the "loaded" Cheerio factory function
is deprecated. Users are encouraged to instead use the load
function
exported by the Cheerio module.
Use the load
function exported by the Cheerio module.
const $ = cheerio.load('<h1>Hello, <span>world</span>.</h1>');
Optional
options: null | CheerioOptionsExtract multiple values from a document, and store them in an object.
An object containing the extracted values.
An object containing key-value pairs. The keys are the names of the properties to be created on the object, and the values are the selectors to be used to extract the values.
Renders 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.
$.merge().
arr1
, with elements of arr2
inserted.
Cheerio.merge
First array.
Second array.
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