Cheerio HTML Parser icon

Cheerio HTML Parser

Parse HTML using Cheerio

Cheerio HTML Parser

AI-generated

Summary

Parse HTML using Cheerio, extracting data via CSS selectors.

Inputs

  • html (required) — The HTML string to parse.
  • selectors (required) — Collection of selector configurations. Each configuration includes a name, CSS selector, optional attribute to extract, and flags for trimming, returning HTML, and returning only the first match.
  • removeElements — Comma-separated list of CSS selectors for elements to remove from the HTML before parsing (e.g., 'script, style').

Output shape

Array of objects matching the number of input items. Each object contains a json field with the following properties:

  • results: Object where keys are selector names and values are either a string (if singleItem true) or an array of strings/values. If an attribute is specified, the attribute value is returned; otherwise the element's text or inner HTML is returned (depending on returnHTML). Values are trimmed when trimText is true. Non‑matched elements are omitted from the array; if singleItem true and no match, an empty string is returned. - totalElements: Total count of elements matched across all selectors. - selectors: Number of selector configurations processed.

Examples

Example 1: Extract article titles and links from a blog page.

HTML: {{$json[“html”]}}. Selectors: [{ name: “title”, selector: “h2.entry-title”, attribute: “”, trimText: true, returnHTML: false, singleItem: false }, { name: “link”, selector: “h2.entry-title a”, attribute: “href”, trimText: false, returnHTML: false, singleItem: false }]. Remove Elements: (empty).

Links

Discussion