Note Cheerio is not a web browser. Cheerio parses markup and provides an API for traversing/manipulating the resulting data structure. It does not interpret the result as a web browser does. Specifically, it does not produce a visual rendering, apply CSS, load external resources, or execute JavaScript which is common for a SPA (single page application). This makes Cheerio much, much faster ...
The wrap() method takes a string or a Cheerio object as an argument and wraps the element in the given element. ... The wrapInner() method works similar to wrap (), but instead of wrapping the element itself, it wraps the element’s inner HTML in the given element.
Have a look at cheerio-select, the library that implements these extensions, to see what is available. For further information, please also have a look at jQuery’s guide on selecting elements, as well as MDN. Finally, to add custom CSS pseudo-classes, have a look at the Extending Cheerio guide.
A walkthrough of different loading methods. Learn more about the load method in the API documentation. loadBuffer The loadBuffer method is similar to the load method, but it takes a buffer containing the document as its argument instead of a string. Cheerio will run the HTML encoding sniffing algorithm to determine the encoding of the document. This is useful when you have the document in ...
Extract multiple values at once. This uses Cheerio’s prop method under the hood. value defaults to textContent, which extracts the text content of the element. As an attribute with special logic inside the prop method, href s will be resolved relative to the document’s URL. The document’s URL will be set automatically when using fromURL to load the document. Otherwise, use the baseURI ...