Recommended Free Tools
How do you scrape a website with Node.js? Start with a page you are allowed to access, request its HTML with Node.js’s built-in fetch, parse the returned markup with Cheerio, extract and validate the fields you need, then save structured records. Use Playwright only when the data appears after JavaScript runs or depends on real browser behavior.
This guide builds that workflow from a single page to a respectful, fault-tolerant scraper. It does not cover bypassing logins, CAPTCHAs, paywalls, or other access controls. Site terms, applicable law, and the target owner’s instructions still matter; neither this article nor robots.txt grants permission.
Before writing code: choose an authorized target
Pick a small, public page whose terms and access conditions permit your intended use. Read the site’s terms, look for an official API, and inspect https://example.com/robots.txt (replace the host). Google explains that robots rules apply to paths on the protocol, host, and port where the file is posted: Google’s robots.txt guide. MDN notes that the file is optional, can communicate crawl preferences, and is not a security boundary: MDN’s robots.txt guide.
- Collect only the fields you need.
- Use a low request rate and avoid parallel bursts.
- Cache pages where practical and stop on errors.
- Do not circumvent authentication, bot checks, CAPTCHAs, rate limits, or explicit technical controls.
Set up a small Node.js project
Use a current Node.js release with the global fetch API; consult the Node.js globals documentation because runtime support can change. Cheerio’s current introduction states that it runs on Node.js 22.19 or later, so verify the requirement before installing.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
- Create a directory and initialize an ES-module project:
mkdir node-scraper cd node-scraper npm init -y npm install cheerio - Add
"type": "module"topackage.json, or use an.mjsfile. - Create
scrape.js. Replace the example URL and selectors only after inspecting the permitted page’s actual HTML.
Request the page with fetch
Always check the response before parsing it. A server can return a 404, an error document, or a login page with a successful network connection. Parsing that response as if it were your target produces misleading records.
const response = await fetch('https://example.com', {
headers: { 'User-Agent': 'BeginnerNodeScraper/1.0 (contact: you@example.com)' },
signal: AbortSignal.timeout(15000)
});
if (!response.ok) {
throw new Error(`HTTP ${response.status} ${response.statusText}`);
}
const contentType = response.headers.get('content-type') || '';
if (!contentType.includes('text/html')) {
throw new Error(`Expected HTML, received ${contentType}`);
}
const html = await response.text();
console.log(`Downloaded ${html.length} characters`);
The timeout prevents a request from hanging forever. Keep the user agent truthful; do not pretend to be a search crawler or browser you are not. For repeated requests, add a delay and retry only transient failures, with a maximum attempt count.
Parse static HTML with Cheerio
Cheerio parses HTML/XML and supplies a jQuery-like traversal and selector API. It is not a browser: it does not render pages, load external resources, or execute JavaScript. Its official introduction is at cheerio.js.org/docs/intro/.
import * as cheerio from 'cheerio';
const response = await fetch('https://example.com');
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const html = await response.text();
const $ = cheerio.load(html);
const title = $('h1').first().text().trim();
console.log({ title });
Selectors are CSS selectors. Prefer stable attributes or semantic elements over fragile chains such as div:nth-child(3) span. A selector that works today is not guaranteed to survive a redesign.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Extract, normalize, and validate records
Suppose an authorized catalog page contains repeated article.product elements with a title, price, and link. This complete example extracts records, normalizes whitespace, validates required fields, removes duplicates, and writes JSON.
import * as cheerio from 'cheerio';
import { writeFile } from 'node:fs/promises';
const url = 'https://example.com/catalog';
const response = await fetch(url, {
headers: { 'User-Agent': 'BeginnerNodeScraper/1.0 (contact: you@example.com)' },
signal: AbortSignal.timeout(15000)
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const html = await response.text();
const $ = cheerio.load(html);
const records = [];
const seen = new Set();
$('article.product').each((index, element) => {
const card = $(element);
const name = card.find('.product-name').first().text().replace(/\s+/g, ' ').trim();
const priceText = card.find('.price').first().text().replace(/\s+/g, ' ').trim();
const href = card.find('a').first().attr('href');
if (!name || !href) return; // incomplete record
const link = new URL(href, url).href;
if (seen.has(link)) return;
seen.add(link);
const price = priceText.match(/[0-9]+(?:[.,][0-9]{1,2})?/);
records.push({
name,
price: price ? price[0].replace(',', '.') : null,
url: link,
source: url,
scrapedAt: new Date().toISOString()
});
});
if (records.length === 0) {
throw new Error('No records found; check the URL, selectors, and page response');
}
await writeFile('products.json', JSON.stringify(records, null, 2));
console.log(`Saved ${records.length} records`);
Why each check matters
- Whitespace normalization removes line breaks and presentation spacing from text nodes.
- Absolute URLs make relative links usable outside the source page.
- Validation prevents blank cards from becoming data.
- Deduplication handles repeated links or responsive markup.
- A zero-record failure alerts you when a selector changed instead of silently producing an empty file.
For CSV output, map each record to escaped columns and write a header. For large datasets, stream records rather than retaining every object in memory, and checkpoint progress so a later run can resume.
Pagination, delays, and resilient crawling
Pagination can be represented by a finite queue of links or a loop that follows a “next” link. Set a hard page limit, track visited URLs, and stop when the next link is missing.
const visited = new Set();
let nextUrl = 'https://example.com/catalog';
const all = [];
for (let page = 0; page < 20 && nextUrl; page++) {
if (visited.has(nextUrl)) break;
visited.add(nextUrl);
const res = await fetch(nextUrl, { signal: AbortSignal.timeout(15000) });
if (!res.ok) throw new Error(`HTTP ${res.status} at ${nextUrl}`);
const $ = cheerio.load(await res.text());
$('.product').each((_, el) => { /* extract and validate as above */ });
const href = $('a[rel="next"]').attr('href');
nextUrl = href ? new URL(href, nextUrl).href : null;
await new Promise(resolve => setTimeout(resolve, 1500));
}
Use exponential backoff for temporary 429 or 5xx responses, honor a server’s retry guidance, and stop after a small number of attempts. Do not turn retries into a flood. Log status codes, URLs, durations, and record counts without storing secrets.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
When do you need Playwright?
First inspect the downloaded HTML. If the desired text, links, or data attributes are present, Cheerio is usually the simpler choice. If the initial response contains only an application shell and the data appears after client-side JavaScript, or if you must interact with menus, scrolling, clicks, cookies, or a logged-in browser session you are authorized to use, consider Playwright. Cheerio’s documentation points to browser automation such as Playwright or Puppeteer for rendering and JavaScript execution; Playwright’s installation and browser setup are documented at playwright.dev/docs/intro.
| Question | Cheerio | Playwright |
|---|---|---|
| Is the data in server-returned HTML? | Yes; parse directly | Works, but adds unnecessary browser setup |
| Does client-side JavaScript create the data? | No execution; content may be absent | Can run the page and wait for selectors |
| Browser interactions required? | Not available | Clicks, navigation, screenshots, and browser APIs |
| Operational complexity | Small dependency and low memory overhead | Browser binaries, contexts, waits, and more failure modes |
| Maintenance | Selectors must match markup | Selectors plus browser flows and timing need maintenance |
Use an official API instead when one supplies the data you need under clearer usage terms. Do not use Playwright to defeat access controls.
Common failures and fixes
HTTP 403, 429, or a bot-check page
Cause: the site denied or throttled the request. Fix: stop, review terms and crawl instructions, reduce frequency, and use an official API or request permission. Do not attempt CAPTCHA or bot-check bypasses.
HTTP 200 but no records
Cause: the response is a login/error page, the selector is wrong, or content is client-rendered. Log the final URL and a small, non-sensitive HTML sample; inspect the response in a browser’s view-source, then choose a correct selector or Playwright.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
“fetch is not defined”
Cause: an old Node.js runtime or a non-Node execution environment. Use a current Node.js release documented at the globals API, or add an HTTP client only if your environment requires it.
Timeouts and partial output
Set a timeout, limit retries, save completed pages, and record failed URLs for a later run. A scraper should fail visibly rather than publish incomplete data as complete.
Selectors break after a redesign
Keep selectors in one configuration area, add validation tests against a saved fixture, and alert when expected fields or record counts change substantially.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If your immediate goal is a clean image or PDF of a page rather than structured fields, ScreenshotNeo provides a one-request website screenshot API and an MCP server for AI agents. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchUse the API documentation at https://screenshotneo.com/docs/:
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
It also supports PNG, JPEG, PDF, full-page and element captures, device presets, custom waits, headers, cookies, JavaScript, blocking rules, caching, signed links, asynchronous webhooks, bulk capture, and an OpenAPI specification. The MCP tools take_screenshot, get_page_info, and capture_pdf work with Claude, Cursor, and other MCP clients.
There is a free allowance of 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is on every plan. Create a free ScreenshotNeo account to try it.
Cost, performance, and reliability decisions
- Request volume: fewer, slower requests are safer for the target and easier to recover.
- Parsing: Cheerio avoids browser startup when HTML already contains the data.
- Browser runs: reserve Playwright for JavaScript and interaction requirements.
- Freshness: cache immutable pages, but define a refresh interval for changing data.
- Quality: store source URL, timestamp, status, and validation outcomes with each batch.
- Security: keep API keys and cookies in environment variables, never in source or logs.
Frequently Asked Questions
Can I scrape any public website with Node.js?
No. Public visibility does not automatically grant permission. Check terms, access conditions, robots instructions, and applicable law, and avoid bypassing controls.
Free tools Windows power users keep installed
One-click scans. No signup required.
How can I tell whether a page needs Playwright?
Fetch the HTML and search it for the desired text or data attributes. If the data is absent until JavaScript executes or an interaction occurs, evaluate Playwright or an official API.
Why does Cheerio return empty text?
The selector may be wrong, the response may be an error or login page, or the content may be client-rendered. Inspect the actual response before changing code.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

