npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

n8n-nodes-cheerio-html-parser

v0.5.8

Published

n8n node to parse HTML using Cheerio

Downloads

257

Readme

n8n-nodes-cheerio-html-parser

This is a custom n8n node that uses Cheerio to parse HTML content.

Features

  • Parse HTML using multiple CSS selectors
  • Convert selected output to array or string
  • Remove unwanted elements (scripts, styles, navigation, etc.) before parsing
  • Extract specific attributes from elements

Installation

  1. Clone this repository
  2. Install dependencies:
npm install
  1. Build the node:
npm run build
  1. Link to your n8n installation:
npm link
  1. In your n8n installation directory, run:
npm link n8n-nodes-cheerio-html-parser

Usage

  1. Add the "Cheerio HTML Parser" node to your workflow
  2. Input the HTML content you want to parse
  3. Add one or more selectors with:
    • Name: A unique identifier for this selector result
    • CSS Selector: The CSS selector to find elements (e.g., "div.content", "p.title", "#main")
    • Attribute (optional): Extract a specific attribute instead of text content
    • Return Single Item: Choose whether to return the first match or all matches
  4. Optionally specify elements to remove before parsing (e.g., "script, style, nav, footer")
  5. Connect the node to your workflow

Example

Input HTML:

<div class="content">
  <h1>Title</h1>
  <p>Some text</p>
</div>

With selector: .content h1 the node will return:

{
  "results": {
    "title": "Title"
  },
  "totalElements": 1,
  "selectors": 1
}

Complete Example

Input HTML:

<div class="article">
  <h1 class="title">Welcome to my blog</h1>
  <div class="content">
    <p>First paragraph of content</p>
    <p>Second paragraph of content</p>
  </div>
</div>

Node Configuration:

{
  "selectors": [
    {
      "name": "title",
      "selector": "h1.title",
      "singleItem": true
    },
    {
      "name": "paragraphs",
      "selector": "div.content p",
      "singleItem": false
    }
  ]
}

Output:

{
  "results": {
    "title": "Welcome to my blog",
    "paragraphs": [
      "First paragraph of content",
      "Second paragraph of content"
    ]
  },
  "totalElements": 3,
  "selectors": 2
}

Advanced Example with Element Removal

Input HTML:

<html>
  <head>
    <script>console.log('analytics');</script>
    <style>.hidden { display: none; }</style>
  </head>
  <body>
    <nav>Navigation Menu</nav>
    <main>
      <h1 class="title">Article Title</h1>
      <div class="content">
        <p>Main content here</p>
      </div>
    </main>
    <footer>Footer content</footer>
  </body>
</html>

Node Configuration:

{
  "removeElements": "script, style, nav, footer",
  "selectors": [
    {
      "name": "title",
      "selector": "h1.title",
      "singleItem": true
    },
    {
      "name": "content",
      "selector": "div.content p",
      "singleItem": true
    },
    {
      "name": "titleClass",
      "selector": "h1.title",
      "attribute": "class",
      "singleItem": true
    }
  ]
}

Output:

{
  "results": {
    "title": "Article Title",
    "content": "Main content here",
    "titleClass": "title"
  },
  "totalElements": 3,
  "selectors": 3
}

Note: The script, style, nav, and footer elements were removed before parsing, so they don't interfere with the content extraction.

Node Structure

The node outputs an object with the following structure:

  • results: An object containing the extracted data, with keys matching the selector names
  • totalElements: The total number of elements found across all selectors
  • selectors: The number of selectors that were processed

Development

To run tests:

npm test

License

MIT