cheerio

cheerio is a cursor rule for Cursor from sanjeed5/awesome-cursor-rules-mdc. It costs 1,487 tokens per session, scanned A, original, CC0-1.0.

A set of rules for using Cheerio, a Node.js library that reads and changes HTML on the server. It is commonly used to select page elements and extract data without opening a browser.

In plain words
What is it for?
Use it to fetch HTML, find elements such as product names and prices, extract their contents, and pass the collected data to storage.
Why use it?
It helps keep web-scraping code organized, efficient, and less likely to fail on missing HTML elements. The guide separates downloading pages, parsing them, and saving results.

Cursor rule for Cursor

Written for Cursor: a Cursor rule (.mdc).

About the project

awesome-cursor-rules-mdc is a generator that creates Cursor MDC rule files from structured library information, using semantic search and language models to gather and organize guidance. Developers use it to produce reusable rules for libraries in Cursor, and the catalogue includes 200 of those rules.

sanjeed5/awesome-cursor-rules-mdc · 3,571 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sanjeed5/awesome-cursor-rules-mdc/cheerio
Clone the repo
git clone --depth 1 https://github.com/sanjeed5/awesome-cursor-rules-mdc

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cheerio

README.md
[![agentmods](https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/cheerio.svg)](https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/cheerio)
Your own site
<a href="https://agentmods.dev/rules/sanjeed5/awesome-cursor-rules-mdc/cheerio"><img src="https://agentmods.dev/badge/rules/sanjeed5/awesome-cursor-rules-mdc/cheerio.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,487 This file is loaded in full into every session.
When invoked 1,487 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01487 $0.01487
Opus 5 $0.00744 $0.00744
Sonnet 5 $0.00297 $0.00297
Haiku 4.5 $0.00149 $0.00149

Measured 6d ago against content hash 9395712033a5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

cheerio scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const { data: html } = await axios.get(url, {
rules-mdc/cheerio.mdc · 173 lines

How it starts

The opening of the file, as written. The whole thing — 173 lines — stays where its author put it; the contents beside it link to each section on GitHub.

cheerio Best Practices

cheerio is your lightweight, server-side jQuery for Node.js, ideal for fast HTML parsing and manipulation. Follow these rules to build efficient, maintainable, and robust scraping solutions.

1. Code Organization & Structure

Always modularize your scraping logic. Separate HTTP requests, HTML parsing, and data persistence. Use async/await for all asynchronous operations.

✅ GOOD: Modular & Asynchronous Structure

// index.js
import * as cheerio from 'cheerio';
import axios from 'axios';
import { writeFile } from 'fs/promises';

async function fetchAndParse(url) {
  try {
    const { data: html } = await axios.get(url, {
      headers: { 'User-Agent': 'YourScraper/1.0' }
    });
    const $ = cheerio.load(html);

    const products = [];
    $('.product-item').each((i, el) => {
      const $el = $(el);
      const name = $el.find('.product-name').text().trim();
      const price = $el.find('.product-price').text().trim();
      const imageUrl = $el.find('img').attr('src');
      
      // Always check for existence before pushing
      if (name) { 
        products.push({ name, price, imageUrl });
      }
    });
    return products;
  } catch (error) {
    console.error(`Error scraping ${url}:`, error.message);
    throw error;
  }
}

async function main() {
  const targetUrl = 'https://www.example.com/products';
  const scrapedData = await fetchAndParse(targetUrl);
  await writeFile('products.json', JSON.stringify(scrapedData, null, 2), 'utf8');
  console.log('Scraping complete. Data saved to products.json');
}

main();

2. Common Patterns & Anti-patterns

2.1. Selector Efficiency

Keep selectors specific and scoped. Avoid broad selectors that force cheerio to traverse large portions of the DOM. Chain .find() for nested elements.

// ❌ BAD: Overly broad, inefficient
const allLinks = $('a').map((i, el) => $(el).attr('href')).get();

// ✅ GOOD: Scoped to relevant section
const productLinks = $('#product-grid a.product-link').map((i, el) => $(el).attr('href')).get();

// ✅ GOOD: Chain .find() for precision
const productName = $('.product-card').first().find('h2.title').text().trim();

Read the full file on GitHub · 173 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 173 lines · 0 tokens per session scan A 9395712033a5

Subscribe to this mod's changes

cheerio is a cursor rule published in the GitHub repository sanjeed5/awesome-cursor-rules-mdc (3,571 stars, last pushed 3mo ago), licensed CC0-1.0. It adds 1,487 tokens to every session, about $0.0074 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.