Skip to main content
The Playwright extractor re-fetches each page in a cold headless browser, then runs trafilatura on the rendered HTML. It is a legacy strategy.
Legacy — not in the default extractor order. The default generic order is ["trafilatura", "newspaper"]. Playwright is only used when you list "playwright" explicitly in EXTRACTOR_ORDER, or when INFINITE_SCROLL is enabled (which re-adds it automatically).For JavaScript-heavy or anti-bot sites, the recommended path is the hybrid browser service — set "BROWSER_ENABLED": true (or "CLOUDFLARE_ENABLED": true for Cloudflare-protected sites). It renders and caches cookies instead of re-fetching every URL in a cold browser, so it is far faster at scale. See Cloudflare Bypass.Reach for Playwright directly only for infinite-scroll pages, or an existing spider already built on it.

When to Use

Infinite scroll pages (auto-enables Playwright via INFINITE_SCROLL)
An existing spider already pinned to "playwright" in EXTRACTOR_ORDER
For new JS-rendered or anti-bot sites, prefer BROWSER_ENABLED / CLOUDFLARE_ENABLED instead — see the warning above.
Slower than HTML-based extractors (newspaper, trafilatura) — a second request per URL
Higher resource usage (browser instance per request)
Use low concurrency (2-4 requests)

Configuration

Basic Playwright

Wait for Selector

Waits for .article-content element (max 30s). Extraction fails if selector doesn’t appear.

Additional Delay

Waits for .loaded element, then waits an additional 5 seconds before extraction.

Infinite Scroll

Settings Reference

PLAYWRIGHT_WAIT_SELECTOR
string
default:"null"
CSS selector to wait for before extractionTimeout: 30 secondsUse when: Content loads via AJAX/fetchExample:
PLAYWRIGHT_DELAY
float
default:"null"
Additional seconds to wait after page loadUse when: Content appears with unpredictable timingExample:
INFINITE_SCROLL
boolean
default:"false"
Enable infinite scroll behaviorNote: Setting this auto-adds "playwright" to EXTRACTOR_ORDER if not already presentExample:
MAX_SCROLLS
integer
default:"5"
Maximum scroll iterationsExample:
SCROLL_DELAY
float
default:"1.0"
Delay between scrolls (seconds)Example:

Identifying JS-Rendered Sites

Signs page needs Playwright:
  1. Minimal HTML: View page source shows almost empty body
  2. Content in script tags: Data exists only as JavaScript objects
  3. Loading placeholders: “Loading…” text or spinner elements
  4. Generic extractors fail: Newspaper/trafilatura return no content
Test without browser:
If HTML is minimal/empty → the page needs browser rendering. Prefer "BROWSER_ENABLED": true (or "CLOUDFLARE_ENABLED": true); use Playwright only for infinite scroll or an existing playwright-based spider.

Common Wait Selectors

Performance Optimization

Reduce Concurrency

Browser instances use significant memory; too many concurrent browsers cause system overload.

Use Playwright Only When Needed

Hybrid Strategy

Most pages use fast trafilatura; only JS-heavy pages trigger Playwright, keeping average concurrency high.

Examples

SPA (React/Vue/Angular)

Delayed Content

Infinite Scroll (Quotes Example)

Note: Set follow: false to prevent following links during scroll.

Cloudflare + Playwright

Debugging

Check Playwright Logs

Look for:

Test Wait Selector

If selector not found → Playwright will timeout (30s)

Common Issues

Timeout waiting for selector:
  • Selector doesn’t exist on page
  • Selector appears after 30s (use PLAYWRIGHT_DELAY instead)
  • JavaScript error prevents rendering
  • Solution: Use generic selector or remove PLAYWRIGHT_WAIT_SELECTOR
Content still empty:
  • Increase PLAYWRIGHT_DELAY
  • Page requires interaction - use INFINITE_SCROLL if applicable