Guides & Tutorials
Web Scraping with Node Js
A practical guide to web scraping with Node.js, covering the leading libraries, an async fetching pattern, headless browsers, and where proxies fit in.
Guides & Tutorials
A practical guide to web scraping with Node.js, covering the leading libraries, an async fetching pattern, headless browsers, and where proxies fit in.
Node.js is a natural fit for web scraping. Its non-blocking, event-driven model handles many simultaneous requests efficiently, and the JavaScript ecosystem includes mature tools for fetching pages, parsing HTML, and driving real browsers. If you are already working in JavaScript, scraping with Node.js keeps your whole pipeline in one language.
This guide covers the libraries worth knowing, a simple async workflow, how to deal with JavaScript-rendered content, and why proxies matter once you move beyond a handful of pages.
Production Node.js scraping turns on four things the basics skip: defeating browser fingerprinting in headless Chromium, building a retry-and-queue layer that survives transient failures, keeping memory under control when running many browser instances, and wiring proxy rotation cleanly into axios or Playwright. Get these right and a fragile script becomes a pipeline that runs unattended.
A few well-chosen packages cover the vast majority of scraping tasks in Node.
For static content, axios plus Cheerio is fast and lightweight. For dynamic pages, a headless browser is the dependable choice. For large structured crawls, Crawlee saves you from rebuilding infrastructure.
Here is a compact example that fetches a page and extracts elements with Cheerio. The async style is idiomatic Node and scales well to many URLs.
import axios from "axios";
import * as cheerio from "cheerio";
async function scrape(url) {
const { data } = await axios.get(url, {
headers: { "User-Agent": "Mozilla/5.0 (compatible; MyScraper/1.0)" },
timeout: 15000,
});
const $ = cheerio.load(data);
$(".product").each((_, el) => {
const name = $(el).find(".name").text().trim();
const price = $(el).find(".price").text().trim();
console.log(name, price);
});
}
scrape("https://example.com/products");
Setting a User-Agent and a timeout from the start makes the scraper more predictable. As you add more URLs, control concurrency so you do not overwhelm the target or your own machine.
When a site builds its content in the browser, the HTML you download is often a near-empty shell. A headless browser renders the page first, then you read the completed DOM.
import { chromium } from "playwright";
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto("https://example.com");
const titles = await page.$$eval("h2", els => els.map(e => e.textContent));
await browser.close();
console.log(titles);
Headless browsers are powerful but resource-hungry, so reserve them for pages that genuinely require rendering and use lightweight HTTP fetching everywhere else.
Node's strength is handling many connections at once, but firing thousands of requests with no limit will get you blocked and may crash your process. Use a concurrency limiter, batch your URLs, and add small randomised delays. Frameworks like Crawlee manage this for you with built-in queues and automatic retries, which is a major reason teams adopt them for serious crawls.
Sustained scraping from a single IP invites rate limits and blocks, and it prevents you from seeing location-specific results. Proxies distribute your requests across many addresses and let you target specific regions.
Datacenter proxies are fast and economical, suiting tolerant targets and high throughput. Residential proxies use real consumer connections, so they blend in better on strict sites at a higher cost. Rotating pools spread load and reduce the chance of any single address being flagged. The best choice depends on your targets and volume.
Since pricing and pool quality differ so much, it is worth comparing providers before you scale. For value-focused developers, Cheapest Proxies is our featured value pick and a strong option when you want dependable proxies without inflating infrastructure costs.
Small jobs can write to JSON or CSV. As volume grows, a database such as PostgreSQL or MongoDB adds querying, deduplication, and durability. Pair that with structured logging and a retry queue so transient failures are replayed rather than lost. These habits turn a fragile script into a maintainable pipeline.
A quick value-first shortlist — Cheapest Proxies leads as the featured pick. Qualitative labels only; confirm exact plans before buying.
| Provider | Best for | Profile | Value |
|---|---|---|---|
| Cheapest Proxies | Budget-conscious buyers comparing affordable proxies | Value Focused | Excellent value |
| Bright Data | Enterprises needing huge pools and compliance controls | Enterprise Focused | Premium |
| Oxylabs | Large-scale scraping and data APIs | Enterprise Focused | Premium |
| Smartproxy (Decodo) | Newcomers who want an easy dashboard | Beginner Friendly | Good |
| SOAX | Precise city and carrier targeting | Automation Friendly | Good |
A default Playwright or Puppeteer browser advertises that it is automated. It exposes the navigator.webdriver flag, ships with a headless user-agent, and presents canvas, WebGL, and font signals that differ from a real user's machine. Sites that run client-side checks read these and block before your scraper sees any content. Stealth plugins patch the most obvious tells, and you can further align the user-agent, viewport, timezone, and locale to look like a coherent real device. Combine that with a residential or ISP proxy whose geography matches the locale you claim, because a US timezone behind a European IP is itself a giveaway. None of this is bulletproof, so reserve heavy stealth for targets that genuinely demand it.
Networks blip, proxies occasionally fail, and targets throttle. Without a queue, a single error can abort a long crawl. Wrap fetches in retry logic with exponential backoff and jitter, cap the attempts, and push permanently failed URLs to a dead-letter list for later inspection. Crawlee provides this out of the box, but a lightweight custom queue using a concurrency limiter works for smaller jobs. Distinguish error classes: a 429 deserves a backoff and proxy swap, a 404 should not be retried at all, and a connection reset usually warrants an immediate retry on a fresh IP.
Headless browsers are the heaviest part of a Node scraper, and the classic failure is a slow memory climb that eventually crashes the process. Each page you open holds resources until closed, and leaked contexts accumulate fast across thousands of URLs. Close pages and contexts deterministically, cap the number of concurrent browser instances, and recycle a browser after a set number of navigations. Browser contexts are the cheap unit of isolation: one Chromium instance can host many contexts, each with its own cookies and proxy, which is lighter than launching a fresh browser per task.
In Node the proxy does not live in the request URL. For axios you attach an HTTP or HTTPS proxy agent (or pass a proxy config) so HTTPS tunnelling works correctly; for Playwright you set proxy options at launch or per context, which lets you bind a different IP to each context. Rotate by drawing from a pool per request or per context and retiring addresses that return blocks. When choosing that pool, compare providers on price and success rate against your real targets; a value-focused option such as Cheapest Proxies is worth evaluating when you want dependable rotation without inflating infrastructure cost.
Start on the smallest sensible tier and scale only what proves itself on your real targets.
Pick the proxy type the task needs first — it drives both success rate and cost more than the logo.
Check traffic limits, rotation rules and what happens on overage before you commit.
Our featured value pick, Cheapest Proxies, is a sensible starting point for affordable comparison.
The running cost of a Node.js scraper is driven largely by proxy bandwidth and browser compute, and providers vary widely on price, pool quality, and success rates against specific sites. Comparing options for your real targets and volumes helps you avoid overpaying for premium residential bandwidth you may not need, while still ensuring your crawl does not stall under blocking.
Compare Proxy Zone weighs providers on value, fit and reliability using qualitative judgement — never invented prices, speeds or uptime figures. See our review methodology, or email info@compareproxyzone.com with a correction.
Yes, its non-blocking model handles many concurrent requests efficiently, and the ecosystem includes strong tools for fetching, parsing, and browser automation in one language.
Use Cheerio with axios for static pages because it is fast and light, and switch to Playwright or Puppeteer when content only appears after JavaScript runs.
Crawlee is a Node scraping framework that adds queues, retries, and proxy rotation, making it well suited to larger structured crawls that need reliable infrastructure.
Small jobs may not, but sustained or large-scale scraping benefits greatly from proxies to distribute requests, avoid rate limits, and reach region-specific results.
Limit concurrency, rotate proxies, set realistic headers, randomise delays, and add retries with backoff so occasional failures do not stop the whole crawl.
Datacenter proxies are faster and cheaper for tolerant targets, while residential proxies blend in better on strict sites at a higher cost; pick based on your targets.
Use JSON or CSV for small jobs and a database like PostgreSQL or MongoDB for larger projects that need querying, deduplication, and durability.
For affordable proxies across the main types, our featured value pick is Cheapest Proxies — a strong budget-friendly option worth considering. Check the exact plan before ordering.