Most pages we need to read for price monitoring and link checking render their content with JavaScript, so a plain HTTP client sees an empty shell. That pushes the crawler toward a headless browser, and in the Node ecosystem the shortlist is almost always Playwright or Puppeteer.

We have run crawlers on both. Each one is a solid choice, and switching between them is less work than people expect. This post compares them on the points that actually changed our crawler design, and then covers the part that matters more than the library: crawling politely and within the rules.

Where they come from

Puppeteer is maintained by the Chrome team. It was built around the Chrome DevTools Protocol and now also supports Firefox through WebDriver BiDi, the cross-browser standard protocol. It is a JavaScript and TypeScript library.

Playwright is maintained by Microsoft and was started by engineers who had worked on Puppeteer. It drives Chromium, Firefox and WebKit, using patched builds of Firefox and WebKit that it downloads itself, and it has official bindings for JavaScript/TypeScript, Python, Java and .NET.

Side-by-side

Area

Puppeteer

Playwright

Engines

Chrome / Chromium, Firefox

Chromium, Firefox, WebKit

Languages

JavaScript / TypeScript

JS/TS, Python, Java, .NET

Isolation

browser.createBrowserContext()

browser.newContext()

Waiting

Locators with auto-wait; explicit waitForSelector

Locators with auto-wait and actionability checks

Request control

page.setRequestInterception(true) + request.continue/abort/respond

page.route() / context.route() with route.continue/abort/fulfill

Test runner

None built in

Playwright Test (optional)

Browser downloads

Chrome for Testing via @puppeteer/browsers

npx playwright install per engine

Isolation: contexts are the unit of work

For crawling, the most important feature in both libraries is the browser context. A context is like a fresh browser profile inside a running browser: its own cookies, local storage, cache and permissions. Creating one takes milliseconds; launching a new browser takes hundreds.

Our worker design is the same with either library: one browser per worker process, one context per crawl job, closed in finally.

// Playwright
const context = await browser.newContext({ userAgent: UA, locale: 'en-US' });
try {
  const page = await context.newPage();
  await page.goto(url, { waitUntil: 'domcontentloaded' });
  // extract
} finally {
  await context.close();
}
// Puppeteer
const context = await browser.createBrowserContext();
try {
  const page = await context.newPage();
  await page.setUserAgent(UA);
  await page.goto(url, { waitUntil: 'domcontentloaded' });
  // extract
} finally {
  await context.close();
}

Playwright lets you set more options at context creation (user agent, locale, timezone, viewport, extra headers, proxy per context). In Puppeteer, several of these are set per page. That is a small difference, but it makes Playwright contexts slightly easier to treat as configuration objects.

Waiting for content

Crawlers fail quietly when they extract before the content is there. Both libraries now have locators that wait automatically.

// Playwright: waits until the element is attached and has text
const price = await page.locator('[data-price]').first().textContent();
// Puppeteer: locator waits for the element before acting
const el = await page.locator('[data-price]').waitHandle();
const price = await el.evaluate((n) => n.textContent);

Playwright's auto-waiting is more complete for interactions: before a click it checks that the element is visible, stable, enabled and receives events. For pure extraction the difference is small. What matters more is the strategy:

  • Prefer waiting for a specific element over waitUntil: 'networkidle'. Pages with analytics beacons or long polling may never become idle, and you pay the full timeout on every page.

  • Never use fixed sleeps. They are either too short under load or waste time on fast pages.

Cutting the cost per page

A crawler does not need images, fonts or video. Blocking them saves bandwidth for you and the site.

// Playwright
await context.route('**/*', (route) => {
  const type = route.request().resourceType();
  return ['image', 'media', 'font'].includes(type) ? route.abort() : route.continue();
});
// Puppeteer
await page.setRequestInterception(true);
page.on('request', (req) => {
  const type = req.resourceType();
  if (['image', 'media', 'font'].includes(type)) req.abort();
  else req.continue();
});

Playwright can register the route once per context, so every page in the job inherits it. In Puppeteer, interception is per page.

Engines: does WebKit matter for a crawler?

Usually not. Chromium renders almost every site the way its users see it. We use WebKit or Firefox only to check whether a site serves different content to different engines, which is rare. If multi-engine coverage matters to you (for example, the same codebase also runs cross-browser tests), Playwright is the natural choice. If you only need Chrome and want the library closest to Chrome's own release cycle, Puppeteer fits well.

Which one we picked

We moved our crawler from Puppeteer to Playwright because our data team writes Python and wanted to own the extraction code. The Python bindings use the same API shape, so the move was mostly mechanical. A team that is all-in on Node and only targets Chrome would have no reason to switch.

The part that matters more: crawling within the rules

The library choice is reversible. Getting blocked, harming a site or collecting data you were not allowed to collect is not.

robots.txt

Neither Playwright nor Puppeteer reads robots.txt for you. Fetch it per host, parse it with a library that follows RFC 9309, and check every URL before queuing it. Cache it (RFC 9309 says crawlers should not use a cached copy for more than 24 hours) and treat a 4xx response as "no rules" and a 5xx response as "disallow everything" until it recovers, as the RFC describes.

if (!robots.isAllowed(url, OUR_UA_TOKEN)) {
  metrics.skippedByRobots.inc({ host: new URL(url).host });
  return;
}

robots.txt is a request from the site owner, not an access control. Following it is the baseline of polite crawling.

Rate limits

  • Limit concurrency per host, not just globally. Ten workers on ten different hosts is fine; ten workers on one small shop is a load test.

  • Add a delay between requests to the same host and honour Crawl-delay if the site sets it, even though it is not part of RFC 9309.

  • On 429 Too Many Requests or 503, back off and respect the Retry-After header.

  • Crawl during the site's off-peak hours for large jobs.

Identify yourself

Use a user agent that names your crawler and includes a URL describing it and how to contact you, such as ExamplePriceBot/2.1 (+https://example.com/bot). Site operators who can reach you will email before they block you.

Terms of service and legal boundaries

This is not legal advice, but these are the lines we hold:

  • Read the site's terms. If they prohibit automated access, get permission or use an official API or feed.

  • Do not crawl behind a login unless you have an agreement that covers it.

  • Do not bypass technical measures such as CAPTCHAs, paywalls or bot challenges. If a site is actively blocking automation, that is the answer.

  • Avoid personal data. If you must process it, data protection law (GDPR in the EU, for example) applies regardless of the data being publicly visible.

  • Respect copyright: extracting a price is different from republishing articles or images.

Talk to your legal team before crawling at scale; the answer depends on your jurisdiction and the sites involved.

Common mistakes

Mistake

Why it hurts

Do this instead

New browser per page

Slow, leaks processes

One browser, context per job

networkidle everywhere

Timeouts on chatty pages

Wait for the element you need

Loading images and fonts

Wasted bandwidth for both sides

Abort non-essential resource types

Global concurrency only

Overloads small sites

Per-host limits and delays

Ignoring robots.txt

Blocked, reputational and legal risk

Check every URL against cached rules

Key takeaways

  • Both libraries handle crawling well; contexts and locators make the core loop the same.

  • Pick Playwright for multi-engine or non-JavaScript teams, Puppeteer for Chrome-focused Node teams.

  • Block heavy resources and wait for specific elements to keep each page cheap.

  • robots.txt, per-host rate limits and a clear user agent are your responsibility, not the library's.

  • Check terms of service and data protection rules before collecting anything at scale.

References