cheeriovshtml5lib
cheerio is a popular JavaScript library that allows you to interact with and manipulate HTML and XML documents in a similar way to how you would with jQuery in a browser. It is a fast, flexible, and lean implementation of core jQuery designed specifically for the server.
One of the main benefits of using cheerio is that it allows you to use jQuery-like syntax to navigate and m anipulate the Document Object Model (DOM) of an HTML or XML document, making it easy to work with.
cheerio supports CSS selectors though not XPath.
html5lib is a pure-python library for parsing HTML. It is designed to conform to the WHATWG HTML specification, as is implemented by all major web browsers.
As html5lib is implemented in pure-python it is significantly slower than alternatives powered by lxml (like parsel or beautifulsoup).
However, html5lib implements a more true html5 parsing which can represent HTML tree more correctly than alternatives.
Example Use
Hello World!
'); // use css selectors console.log($('title').text()); // My title console.log($('.name').text()); // Hello World! // select multiple elements const $ = cheerio.load('- item 1
- item 2