
The industry standard for working with HTML in JavaScript | Cheerio
Aug 3, 2015 · cheerio The fast, flexible & elegant library for parsing and manipulating HTML and XML. Get Started!
Introduction | Cheerio
Download the latest version of Node.js: ... npm install cheerio ... import * as cheerio from 'cheerio'; ... const cheerio = require('cheerio'); ... const $ = cheerio.load('<h2 class="title">Hello world</h2>'); ...
basics/manipulation.md | Cheerio
The wrap() method takes a string or a Cheerio object as an argument and wraps the element in the given element. // Wrap an element in a div $('p').wrap('<div></div>');
API Documentation | Cheerio
Element [K] ... prop<T, K>( this, name, value): Cheerio<T>; Defined in: src/api/attributes.ts
basics/selecting.md | Cheerio
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.
basics/loading.md | Cheerio
import * as cheerio from 'cheerio'; const $ = await cheerio.fromURL('https://example.com'); Learn more about the fromURL method in the API documentation.
The `extract` method | Cheerio - JS.ORG
import * as cheerio from 'cheerio'; const $ = cheerio.load(` <ul> <li>One</li> <li>Two</li> <li class="blue sel">Three</li> <li class="red">Four</li> </ul> `); ... // Extract the text content of the first .red element …
basics/traversing.mdx | Cheerio
import * as cheerio from 'cheerio'; const $ = cheerio. load( `<ul> <li>Item 1</li> </ul>`, ); const list = $('li'). parent(); console. log(list. prop('tagName')); ... The parents method allows you to select all …
advanced/configuring-cheerio.md | Cheerio
This may be the case for those upgrading from pre-1.0 releases of Cheerio (which relied on htmlparser2), for those dealing with invalid markup (because htmlparser2 is more forgiving 1), or for …
advanced/extending-cheerio.md | Cheerio
const $ = cheerio.load('<html><body>Hello, <b>world</b>!</body></html>'); $.prototype.logHtml = function () { console.log(this.html()); }; $('body').logHtml(); // logs "Hello, <b>world</b>!" to the …