JavaScript Web Scraping Libraries: Choosing by Page Type
The right JavaScript scraping tool depends on where the data lives. Static markup calls for a light parser, rendered pages call for a real browser, and multi-page jobs call for crawl infrastructure. This guide maps each option to the job it handles best, with trade-offs you can check before you commit.
A decision check before choosing a library
Start by inspecting the response you receive. If the needed text is already present in the delivered markup, a parser is enough. If the text appears only after scripts run, or if you must click, scroll, log in or fill a form, you need browser automation. If you must follow links across many pages, add a crawler layer for queues, retries, duplicate handling and concurrency. A practical decision check: fetch one page first; if selectors find the data, stay with HTTP plus a parser; if the data is missing until rendering, move up a tier; if the job grows beyond a handful of URLs, move to a framework instead of hand-building scheduling.
Playwright for rendered and interactive pages
Playwright launches a real browser, executes page scripts, waits for elements and supports interaction such as clicking, scrolling and form entry across Chromium, Firefox and WebKit. Automatic waiting, locators, isolated contexts and network interception reduce glue code in new projects. The cost is higher CPU and memory, browser binaries and system dependencies, and it is unnecessary when data is already in HTML or an API. A real browser also does not guarantee avoidance of anti-bot detection. Protected modules code0001 and code0002 contain the install and example contract for this tool.
Selenium WebDriver when breadth and existing infrastructure matter
Selenium WebDriver is a long-established browser automation option supporting Chrome, Firefox, Edge and Safari, with Selenium Manager handling drivers in most cases and Selenium Grid supporting distributed sessions. It covers the same rendered-page scenarios as Playwright, but its JavaScript API is more verbose and waiting must often be made more explicit. It remains a sensible choice when Safari support, existing Selenium tests or Grid infrastructure matter. Protected modules code0003 and code0004 contain the install and example contract.
Puppeteer for Chrome-centred automation
Puppeteer provides Chrome-focused automation with a mature API, modern locators with automatic waiting, isolated contexts and fine-grained browser and network control. Current versions also support Firefox through WebDriver BiDi, while Chrome uses the Chrome DevTools Protocol by default. It handles single-page applications, lazy-loaded content, forms, screenshots and PDFs, but has no WebKit or Safari support and carries full-browser resource costs. Protected modules code0005 and code0006 contain the install and example contract.
Cheerio for fast static HTML parsing
Cheerio parses HTML or XML without running a browser and offers a familiar jQuery-style querying API. It can fetch a URL directly, load existing markup, handle streams and buffers, and extract structured data with extract(). It is well suited to blogs, product pages, documentation and server-rendered pages. It does not execute client-side JavaScript or perform clicks or scrolling, so rendered-only content requires an API call or a browser tool. Protected modules code0007, code0008 and code0009 contain the install and example contracts.
JSDOM for browser-like DOM APIs without a browser
JSDOM emulates a substantial part of the web platform in Node.js, including document, querySelector(), events, cookies and localStorage, without launching a real browser. It can fetch a page with JSDOM.fromURL() and can execute scripts only when explicitly enabled. It is not a complete browser: many APIs are missing or incomplete, navigation does not load new pages, and external resources are not loaded by default. Enabling script execution on untrusted pages is unsafe, so a real browser is the safer choice when complex client-side behaviour is required. Protected modules code0010 and code0011 contain the install and example contracts.
Crawlee for multi-page crawling systems
Crawlee adds crawl infrastructure above individual page handling: request queues, retries, concurrency, sessions, proxy configuration, persistent datasets and link discovery. It offers CheerioCrawler for HTTP-based work, PlaywrightCrawler for browser work and PuppeteerCrawler for Puppeteer-based work, with similar APIs across engines. Start with CheerioCrawler when JavaScript rendering is not needed. Browser crawlers still incur browser costs, and Playwright or Puppeteer must be installed separately. Protected modules code0012, code0013 and code0014 contain the install and example contracts.
Crawler for lightweight HTTP crawling
Crawler, also known as node-crawler, is a lighter HTTP crawler with a request queue, concurrency control, retries, rate limiting, priorities, proxy support and Cheerio parsing by default. It does not execute JavaScript or provide browser automation. The current v2 line is native ESM, uses got, supports HTTP/2 and requires Node.js 22 or newer. It is smaller than Crawlee and requires you to discover and enqueue links yourself. Protected modules code0015 and code0016 contain the install and example contracts.
htmlparser2 for fast and streaming parsing
htmlparser2 is a low-level parser for fast HTML and XML handling, including streaming input and callback-driven processing of tags and text. It can process a fetch() response as chunks arrive without building a full DOM, which helps with large documents or when only links, metadata or specific tags are needed. parseDocument() and DomUtils are available when a DOM is preferred. Compared with Cheerio it offers more direct control but less convenience; CSS selectors require a separate package. Protected modules code0017, code0018 and code0019 contain the install and example contracts.
Native Node.js fetch for dependency-free requests
Modern Node.js includes fetch(), so downloading HTML, JSON or API responses may need no extra HTTP dependency. It uses the familiar Web API and is powered internally by Undici, and it supports streaming response bodies. It does not parse HTML, execute JavaScript or provide crawling features. Pair it with Cheerio, JSDOM or htmlparser2 for static extraction. Installing Undici separately remains useful when lower-level control or connection pooling is needed. Protected modules code0020 and code0021 contain the example contracts.
parse5 for standards-compliant handling of malformed HTML
parse5 implements the WHATWG HTML parsing specification and repairs malformed markup in the way browsers do, rather than treating HTML as generic XML. It parses documents and fragments, serializes trees back to HTML and can preserve source-location information. It has no built-in CSS selector API, does not fetch pages or execute JavaScript, and is lower-level than Cheerio or JSDOM for everyday extraction. It is most useful as reliable parsing infrastructure or when standards-compliant handling of broken markup matters. Protected modules code0022 and code0023 contain the install and example contracts.
Hosted scraping APIs as an alternative deployment model
A hosted scraping API is a different deployment model from a local library: instead of installing browsers and managing proxies yourself, you send a URL and the service handles rendering and infrastructure. The protected example in code0024 uses {{OWNER_HOSTED_API_BASE_URL}} with render_js and extract_rules to return structured JSON, using the credential variable {{OWNER_API_KEY_ENV_VAR}}. Feature and trial claims for any hosted service require owner confirmation through {{OWNER_HOSTED_SERVICE_NAME}} and {{OWNER_TRIAL_CREDITS}} before publication.
Features to weigh for each job type
Match features to the job rather than chasing the longest feature list. Static HTML work benefits from fast parsing, convenient selectors and low memory use. Dynamic work benefits from reliable waiting, JavaScript execution, sessions, network interception and interaction support. Large crawls benefit from queues, retries, concurrency limits, duplicate detection, rate limiting, session management and persistent storage. At larger scale, proxy support, geolocation, observability and multi-machine execution may also matter.
Operating practices that prevent scale failures
Begin with the simplest approach that works and add complexity only when the target demands it. Limit concurrency, retry temporary failures such as timeouts and 5xx responses without retrying every error indefinitely, respect rate limits and 429 responses, reuse sessions and connections, and set sensible timeouts. Keep selectors reasonably specific, validate extracted data, log failures and store progress so larger crawls can resume. Test against realistic workloads, because failures often appear only after hundreds of requests. A browser alone does not solve blocking; request behaviour, sessions, proxies and target restrictions may also matter.
| Need | Tool |
|---|---|
| Modern browser automation for JavaScript-heavy sites | Playwright |
| Mature browser automation with broad browser support and Selenium Grid | Selenium WebDriver |
| Chrome-focused browser automation with a mature API | Puppeteer |
| Fast scraping of static or server-rendered HTML | Cheerio |
| Browser-like DOM APIs without launching a real browser | JSDOM |
| Full crawling framework with queues, retries, sessions, storage and browser support | Crawlee |
| Lightweight HTTP crawling with queues and Cheerio | Crawler |
| Fast, low-level or streaming HTML parsing | htmlparser2 |
| Standards-compliant parsing of malformed HTML | parse5 |
| Simple HTTP requests with no extra dependency | Node.js fetch() |
Match the tool to the page and scale; browser tools are heavier than HTTP parsers.
Frequently asked questions
What is the best JavaScript web scraping library in 2026?
No single library fits every project. Playwright suits JavaScript-heavy pages, Cheerio suits fast parsing of static HTML, and Crawlee suits larger crawls needing queues, retries, sessions and concurrency control.
What is the best JavaScript web scraping library for dynamic websites?
Playwright, Puppeteer and Selenium WebDriver are the main options when JavaScript rendering or interaction is required. Playwright is often a convenient starting point for new Node.js projects.
What is the best JavaScript web scraping library for static websites?
Cheerio is usually the simplest choice for static or server-rendered pages. Pair it with Node.js fetch() to download HTML and extract data without launching a browser.
Is Playwright better than Selenium for web scraping?
Not always. Playwright is often more convenient in modern JavaScript projects, while Selenium offers broad browser support and a mature ecosystem. Your browser requirements and existing stack should decide.
Can I scrape websites in Node.js without a headless browser?
Yes. When data is already in HTML or available through an API, Node.js fetch() can be combined with Cheerio, htmlparser2, JSDOM or parse5. That approach is usually faster and uses fewer resources than running a browser.