NEWStandard createTask and in.php APIs. Change the address and you are connected.View API docs
GATESOLVER

Glossary

Cheerio: server side HTML parsing for Node.js

Cheerio is a Node.js library that loads an HTML string and gives you the familiar jQuery style dollar function to select, read and change elements, without starting a browser.

Why people pick it

Cheerio is small and fast. It parses markup into a tree and implements the parts of the jQuery API that make sense on a server: selectors, traversal, attribute and text access, and manipulation. There is no rendering, no layout and no script execution, so parsing thousands of pages takes a fraction of the memory and time a headless browser would need. For static pages, that makes it the default choice in many Node.js scrapers.

Basic use

import * as cheerio from "cheerio";

const res = await fetch("https://quotes.toscrape.com/");
const $ = cheerio.load(await res.text());
const quotes = $(".quote").map((_, el) => ({
  text: $(el).find(".text").text(),
  author: $(el).find(".author").text(),
})).get();
console.log(quotes.slice(0, 3));

Cheerio does not fetch pages itself; pair it with the built in Fetch API, Axios or another client. Recent versions also offer helpers that fetch and load in one call; check the current documentation for what your version includes.

Limits to keep in mind

  • No JavaScript. If the content appears only after scripts run, Cheerio sees the empty shell. Look for the data in a JSON endpoint or an inline script, or render the page first and pass the resulting HTML to Cheerio.
  • No layout. Visibility and computed styles do not exist, so selectors like :visible from jQuery are not available.
  • Parser behavior. Cheerio can use different underlying parsers; very broken HTML may produce a tree that differs from what a browser builds.

Reading inline data

Modern frameworks often embed the page state as JSON inside a script tag. Selecting that tag and parsing its text gives you the full data model without touching visible markup, and it is usually more stable than class names.

const raw = $("script#__NEXT_DATA__").text();
const state = raw ? JSON.parse(raw) : null;
const listing = state?.props?.pageProps?.listing;

When the HTML is a challenge

A plain HTTP client gets challenged more often than a browser, because its TLS fingerprint and headers do not match a real browser. Check for challenge markers right after loading: a widget with data-sitekey, a title such as "Just a moment...", or a 403 or 503 status. For a widget, read the key with $("[data-sitekey]").attr("data-sitekey"), create a token task with GateSolver and post the form with the token. For a full Cloudflare challenge page, a challenge task returns a cf_clearance cookie bound to your proxy; send it with the same proxy and user agent on the following requests. The clearance typically takes under 10 seconds, and failed tasks are free.

Where it fits in a crawler

Cheerio is a parsing layer. For queues, retries and concurrency, frameworks such as Crawlee include a Cheerio based crawler that combines HTTP fetching, parsing and a persistent request queue, and can switch to a browser crawler for pages that need rendering.

Common questions

Does Cheerio run JavaScript on the page?

No. It only parses the HTML string it receives, so content added by scripts is missing.

Is Cheerio the same as jQuery?

It implements a jQuery style API for server side parsing, without the browser parts such as events and animations.

What should I use to download pages for Cheerio?

The built in fetch, Axios or any HTTP client. Cheerio then parses the text you pass in.

Why does my Cheerio scraper get challenged more than a browser?

Plain HTTP clients have TLS and header patterns that differ from real browsers, which bot checks notice.

Can Cheerio read JSON embedded in a page?

Yes. Select the script tag that holds it, take its text and parse it with JSON.parse.

Keep reading