cheerio
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
cheerio-select | 2.1.0 | 11.79 kB | BSD-2-Clause | prod | |
dom-serializer | 2.0.0 | 6.66 kB | MIT | prod | |
domhandler | 5.0.3 | 12.29 kB | BSD-2-Clause | prod | |
domutils | 3.1.0 | 23.28 kB | BSD-2-Clause | prod | |
htmlparser2 | 8.0.2 | 37.62 kB | MIT | prod | |
parse5-htmlparser2-tree-adapter | 7.0.0 | 3.73 kB | MIT | prod | |
parse5 | 7.1.2 | 86.24 kB | MIT | prod |
Cheerio is a tiny, fast, and elegant Node.js library that implements the core functionality of jQuery. It is specifically designed for server use and is mainly used for web scraping purposes. It works with a simple, consistent DOM model making parsing, manipulating, and rendering incredibly efficient. Cheerio does not produce a visual rendering, does not apply CSS, does not load external resources, or execute JavaScript. This sets it apart from a traditional web browser and makes it much quicker and efficient.
Cheerio is easy to integrate and use in your JavaScript or TypeScript code. After installing the package using npm, you can load HTML content into Cheerio and then manipulate and traverse the DOM just like you would with jQuery. Here's an example of how you can use Cheerio:
const cheerio = require('cheerio');
const $ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text('Hello there!');
$('h2').addClass('welcome');
$.html();
//=> <html><head></head><body><h2 class="title welcome">Hello there!</h2></body></html>
Cheerio provides a familiar jQuery-like syntax for selecting, traversing, and manipulating the DOM. You can change text, add classes, and even select elements using CSS selectors.
You can find detailed information about the use of Cheerio in its official documentation, which is available on the GitHub repository at git://github.com/cheeriojs/cheerio.git. The GitHub repository provides complete and thorough documentation of the API, as well as examples of how to use the library. For an in-depth understanding of Cheerio and its application, the documentation is the best place to start.