Skip to content
Web Scraping

Web Scraping With Cheerio and node.js: A Complete Guide

Learn web scraping with Cheerio and Node.js, from setup and code examples to avoiding IP blocks with proxies.

Rectangle Zenezen
August 24, 2026 2 min read
Web Scraping With Cheerio and node.js  A Complete Guide
Click Here to Add Proxyon as a Trusted Source Add as a preferred source

Don't want to read?

Time is a precious resource, get the insights you need using your favorite AI chat.



What Is Cheerio and How It Works

What Is Cheerio and How It Works

Cheerio turns raw HTML into a queryable document. You load the markup, select elements with CSS selectors, and extract text, attributes, or links. The full API lives on the official Cheerio site.

The keyword here is static. Cheerio only sees the HTML the server sends back, so JavaScript-built pages return an empty shell.


Building a Cheerio Scraper Step by Step

Building a Cheerio Scraper Step by Step

Cheerio parses HTML but does not fetch it, so you need an HTTP client, and Axios is the standard pairing. With Node.js installed:

  1. Create a project folder and run npm init -y
  2. Install the dependencies with npm install axios cheerio
  3. Create a file named scraper.js

Here is a working example:

JAVASCRIPT
const axios = require('axios');
const cheerio = require('cheerio');

async function scrape(url) {
  const { data } = await axios.get(url);
  const $ = cheerio.load(data);
  const titles = [];
  $('h2').each((i, el) => {
    titles.push($(el).text().trim());
  });
  console.log(titles);
}

scrape('https://example.com');

Run it with node scraper.js. The $ object works like jQuery: chain selectors, loop with .each(), pull attributes with .attr().

Also Read: Node.js Proxy Setup With Axios


Cheerio vs. Puppeteer: Which Should You Use

Cheerio vs. Puppeteer  Which Should You Use

Cheerio is fast but blind to JavaScript. Puppeteer renders everything through a full Chromium browser but burns far more CPU, memory, and bandwidth per request. If the data shows in the page source, use Cheerio. If it loads client-side, Puppeteer is the answer.


Avoiding Blocks While Scraping

Avoiding Blocks While Scraping

Hundreds of fast requests from one IP is the clearest bot signal a site can see. Residential proxies fix this by rotating your IP with every request, while datacenter proxies bring more speed at a lower cost on easier targets. Also set a realistic User-Agent header, since the default Axios one gets flagged instantly.

Also Read: How to Do Web Scraping Without Getting Blocked


FAQ Section

Is Cheerio good for web scraping?

Yes, for static HTML it is one of the fastest options.

Can Cheerio execute JavaScript?

No. It parses markup only, without script execution or rendering.

What is the difference between Cheerio and jQuery?

Cheerio brings the jQuery API to server-side HTML strings.

Do I need Axios to use Cheerio?

Any HTTP client works, including Node's built-in fetch.

Can Cheerio be used in a browser?

It can be bundled, but browsers already have a native DOM.

Is web scraping with Cheerio legal?

Scraping public data is generally legal, but terms of service and data laws vary, so check both first.


Final Thoughts

Cheerio is the right call when the data you need lives in static HTML. It runs faster and cheaper than any headless browser, and setup takes minutes. What it cannot solve on its own is getting blocked, and that comes down to your IPs. Proxyon handles that with pay-as-you-go proxies, no subscriptions, just deposit and start scraping.

Get back to building.

We'll handle the proxies.