Skip to main content
@talosjs/html wraps Cheerio in a small, typed Html class for parsing HTML and pulling out structured data. Load markup from a string or a URL, then call focused extractors that return plain typed objects for images, links, headings, videos, and checkbox tasks. It’s built for scraping and content analysis rather than DOM mutation.

Installation

Install the package with Bun.

Usage

Create an Html instance with a markup string (or empty), then query it. All extractors return typed arrays you can iterate directly.

Loading from a URL

Use loadUrl to fetch and parse a remote page. It returns the instance, so you can chain an extractor right away.
You can also reuse an instance and swap its content with load, which returns this for chaining.

Extracting videos and tasks

getVideos collects <video> elements with their attributes and nested <source> tags, and getTasks reads checkbox list items.
You can also get the serialized markup back with getHtml().

What you’d reach for it for

Most uses come down to parsing markup and pulling specific things out of it. You might fetch a remote page with loadUrl and collect its links, images, or headings; build a table of contents from getHeadings(); gather media references through getImages and getVideos; read checkbox task lists (say, from rendered Markdown) with getTasks(); or grab a document’s clean text via getContent(). It’s not the tool for building or templating HTML strings, and if you’re in a browser with direct DOM access you already have what it provides. Reach for it when you need to parse and extract from existing markup on the server.