Cheerio HTML Parser
AI-generatedSummary
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 (ifsingleItemtrue) 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 onreturnHTML). Values are trimmed whentrimTextis true. Non‑matched elements are omitted from the array; ifsingleItemtrue 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).