```yaml
product: AlterLab
title: "How to Scrape Data with Node.js | AlterLab | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/how-to/scrape-data-nodejs
```

Beginner4 steps

# How to Scrape Data with Node.js

Node.js is an excellent platform for web scraping pipelines — native async/await makes concurrent requests natural, and the npm ecosystem provides powerful HTML parsing tools. This guide covers the complete setup using modern Node.js.

## Step-by-Step Guide

1

### Install Cheerio for HTML parsing

Run `npm install cheerio` to install Cheerio — a server-side jQuery implementation for parsing HTML. No headless browser needed — AlterLab handles rendering.

2

### Fetch a page using the AlterLab API

Use Node.js native fetch (Node 18+) or axios to POST to the AlterLab API. Pass your URL and API key in the request body.

3

### Parse with Cheerio

Load the returned HTML into Cheerio with `cheerio.load(html)`. Use jQuery-style selectors to extract the data you need.

4

### Process and save results

Write results to a JSON file with `fs.writeFileSync`, send to a database, or pipe to further processing steps.

## Code Example

TypeScript

```
import * as cheerio from "cheerio";
import fs from "fs";

const API_KEY = "YOUR_API_KEY";

async function scrapePage(url: string) {
  const response = await fetch("https://alterlab.io/api/v1/scrape", {
    method: "POST",
    headers: {
      "X-API-Key": API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ url, render_js: "auto" }),
  });

  const data = await response.json();
  const $ = cheerio.load(data.html);

  const results: string[] = [];
  $("h2.article-title").each((_i, el) => {
    results.push($(el).text().trim());
  });

  fs.writeFileSync("output.json", JSON.stringify(results, null, 2));
  console.log(`Extracted ${results.length} items`);
}

scrapePage("https://example.com/articles");
```

Replace `YOUR_API_KEY` with your key from the . No credit card required.

## Try this yourself with AlterLab

Run this tutorial on live websites with AlterLab's API. New accounts get up to 5,000 free requests — no credit card required.

[View API docs](https://alterlab.io/docs/api/rest)

## Frequently Asked Questions

### Can I use Puppeteer or Playwright instead of Cheerio?

You can, but it's unnecessary when using AlterLab — the API already handles browser rendering on the server side. Using Cheerio to parse the returned HTML is simpler, faster, and uses fewer resources than running a local browser.

### How do I scrape multiple URLs concurrently in Node.js?

Use `Promise.all()` with an array of fetch calls to send multiple requests concurrently. Add a concurrency limiter like the `p-limit` package to avoid overwhelming the target server.

### Responsible Use

AlterLab is designed for extracting publicly available data. Always review the terms of service for any website you access, respect `robots.txt` directives, and ensure your use case complies with applicable laws in your jurisdiction.

### More tutorials

Browse all [how-to guides](https://alterlab.io/how-to) for web scraping — from beginner extractions to advanced multi-page pipelines.

## Your first scrape. Sixty seconds.

Up to 5,000 free requests — about 5,000 Light, 500 Protected or 250 Dynamic requests. No credit card. 
Just a POST request.

terminal

curl -X POST https://api.alterlab.io/v1/scrape \

-H "X-API-Key: YOUR_KEY" \

-H "Content-Type: application/json" \

-d '{"url": "https://example.com", "formats": ["markdown"]}'

[Start building free](https://alterlab.io/signin)

No credit card required · Up to 5,000 free requests (about 5,000 Light, 500 Protected or 250 Dynamic requests) · Balance never expires