TL;DR: Web scraping with JavaScript and Node.js needs Node.js 22.12 or later, the built-in fetch for requests, and Cheerio to parse HTML. Use Cheerio when the data is in the HTML your request receives, and Playwright when JavaScript builds the page or it needs clicks and waits. This guide builds one scraper, from pagination and hidden JSON to offline tests and a scraper API fallback.
Web scraping with JavaScript starts with a simple job: the data sits on a web page, you write JavaScript, and you want that data as clean JSON without fighting blocks or empty arrays. If the idea is new to you, read what web scraping is first.
This guide uses books.toscrape.com, a practice bookstore built for scrapers, as its running example. You'll fetch and parse a page with native fetch and Cheerio, crawl a paginated catalog politely, check whether JavaScript builds a page, render and click through pages with Playwright, test your parser offline, and move blocked pages to a scraper API without changing the parser.
Quick start
- Use Node.js 22.12 or later (24 or 26 LTS recommended)
npm install cheeriofor pages whose data is in the HTMLnpm install playwrightfor pages that need a real browser- Check robots.txt and the site's terms before you crawl




