October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk8 min

How to Scrape Websites in Stealth Mode with Puppeteer and Playwright

Learn how to use Puppeteer or Playwright for authorized scraping without treating stealth as invisibility. Includes runnable examples, session guidance, troubleshooting, and a screenshot-only alternative.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For authorized scraping, “stealth” is best treated as reducing avoidable failures by keeping browser, session, and network behavior coherent—not as a way to become invisible or defeat a site’s defenses. Start with ordinary Puppeteer or Playwright automation, wait for the content you need, inspect what failed, and stop if the site explicitly blocks access. When a site offers an API, export, feed, or permissioned integration, use that instead.

What stealth mode can—and cannot—do

Websites may use several kinds of signals to assess automated traffic. Browserless’s vendor-authored article “Stealth Scraping with Puppeteer or Playwright at Scale,” published January 23, 2026, discusses IP and ASN reputation, HTTP and TLS hints, browser-fingerprint consistency, behavioral timing, and challenges. That is Browserless’s account of possible detection signals, not a complete model that every site uses.

As an Amazon Associate I earn from qualifying purchases.

Browserless Developer Advocate Alejandro Loyola summarizes the vendor’s advice this way: “Stealth scraping means your browser signals line up.” The practical point is to avoid contradictory settings and diagnose failures before changing configuration. It is not a guarantee that a site will accept automation. Detection methods and page behavior can change, and a configuration change can break a page as easily as it can fix one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use automation only where you have permission. The IETF’s RFC 9309, published in September 2022, standardizes the Robots Exclusion Protocol: robots.txt gives crawler guidance, but it is not access authorization or a substitute for reviewing applicable terms and legal requirements. Puppeteer’s project security policy likewise places responsibility for safe and intended automation use on the calling code; that is project guidance, not a legal conclusion.

Choose Puppeteer or Playwright for your constraints

Neither framework is an evidenced universal “stealth winner.” Choose based on the browser and protocol you need, your existing stack, session model, debugging needs, and deployment environment.

Decision What to check
Existing code and team experience Prefer the framework your team can maintain and debug. Rewriting working automation solely to change frameworks is not a detection strategy.
Browser engines Confirm which browser engines your task requires and which connection mode you plan to use. Playwright’s API reference says its Chrome DevTools Protocol (CDP) connection support is limited to Chromium and has lower fidelity than its Playwright-protocol connection.
Session isolation Playwright browser contexts isolate cookies and local and session storage. That makes contexts useful for repeatable runs and separating authorized sessions.
Debugging and traces Decide what you need to retain: navigation errors, response statuses, logs, screenshots, or traces. Keep only the data needed for diagnosis and the intended session.
Deployment and operations Consider browser installation, container compatibility, concurrency, network access, data handling, and the time required to maintain the setup.

Playwright’s isolation and connection features are useful engineering characteristics; they do not, by themselves, establish that Playwright is more or less detectable than Puppeteer.

Build an authorized workflow before changing browser signals

  1. Confirm the access path. Check for an official API, export, feed, or permissioned integration. Review the site’s terms and crawler guidance before automating.
  2. Start with the defaults. Use the minimum browser setup needed to load and extract the permitted content. Do not begin by spoofing identity values or adding a stack of stealth modifications.
  3. Set only task-relevant context values. Choose locale, timezone, and viewport deliberately when the task requires them. Set permissions only when needed. Keep user-agent-related settings and request behavior coherent rather than presenting conflicting identities.
  4. Wait for the actual content. Prefer a relevant selector or page state over a guessed delay. A page can finish navigating before its JavaScript-rendered data appears.
  5. Keep state intentionally. Use a fresh context when a run should have isolated cookies and storage. Preserve only the session state needed for an authorized workflow, and keep it separate from unrelated work.
  6. Record the failure category. Distinguish navigation errors, unsuccessful responses, missing rendered content, expired session state, rate limiting, and explicit access denial before making changes.
  7. Stop at an explicit denial. A CAPTCHA, block page, or repeated denial is a reason to pause, seek permission, or use another data source—not a prompt to escalate evasion.

Playwright: a minimal, selector-based example

This Node.js example opens a page, waits for a selector that indicates the permitted content is present, logs the main navigation response, extracts text, and closes the browser even if an error occurs. It does not spoof a user agent, solve challenges, or try to bypass a block.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Install Node.js and create a project, then install Playwright: npm init -y and npm install playwright.
  2. Save the script below as scrape.mjs. Set TARGET_URL and TARGET_SELECTOR to a site and content selector you are authorized to access.
  3. Run it with TARGET_URL='https://example.com' TARGET_SELECTOR='main' node scrape.mjs. Replace the example URL and selector as needed.
import { chromium } from 'playwright';

const url = process.env.TARGET_URL;
const selector = process.env.TARGET_SELECTOR;
if (!url || !selector) {
  throw new Error('Set TARGET_URL and TARGET_SELECTOR for an authorized page.');
}

const browser = await chromium.launch({ headless: true });
try {
  const context = await browser.newContext({
    locale: 'en-US',
    timezoneId: 'UTC',
    viewport: { width: 1365, height: 900 },
  });
  const page = await context.newPage();
  page.on('requestfailed', request => {
    console.error('Request failed:', request.url(), request.failure()?.errorText);
  });

  const response = await page.goto(url, {
    waitUntil: 'domcontentloaded',
    timeout: 30000,
  });
  console.log('Navigation status:', response?.status() ?? 'no main response');

  await page.locator(selector).waitFor({ state: 'visible', timeout: 15000 });
  const text = await page.locator(selector).innerText();
  console.log(text);
  await context.close();
} finally {
  await browser.close();
}

Set the locale, timezone, and viewport to values appropriate for the job; they are examples, not magic fingerprint settings. If the site’s permitted workflow requires a different locale or viewport, configure that deliberately. Grant permissions only when the task needs them. For an authorized workflow that requires continuity, save and load the relevant Playwright storage state using Playwright’s documented state APIs, and protect that state as session data. Otherwise, use a fresh context so cookies and storage do not carry over.

Puppeteer: the equivalent minimal workflow

Puppeteer can follow the same diagnosis-first pattern. Install the package with npm install puppeteer, save this as scrape-puppeteer.mjs, and run it with the same environment variables. Puppeteer’s package manages a compatible browser for its standard installation; follow its installation guidance if your deployment uses a separately managed browser.

import puppeteer from 'puppeteer';

const url = process.env.TARGET_URL;
const selector = process.env.TARGET_SELECTOR;
if (!url || !selector) {
  throw new Error('Set TARGET_URL and TARGET_SELECTOR for an authorized page.');
}

const browser = await puppeteer.launch({ headless: true });
try {
  const page = await browser.newPage();
  page.setDefaultNavigationTimeout(30000);
  page.on('requestfailed', request => {
    console.error('Request failed:', request.url(), request.failure()?.errorText);
  });

  const response = await page.goto(url, { waitUntil: 'domcontentloaded' });
  console.log('Navigation status:', response?.status() ?? 'no main response');

  await page.waitForSelector(selector, { visible: true, timeout: 15000 });
  const text = await page.$eval(selector, element => element.innerText);
  console.log(text);
} finally {
  await browser.close();
}

For repeated jobs, make lifecycle and concurrency explicit: reuse a browser process only when appropriate, isolate sessions, close pages and contexts when finished, and cap concurrent work to a level the target and your environment permit. Do not turn an error into an unlimited retry loop.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If the result you need is a visual capture rather than extracted page data, ScreenshotNeo is a screenshot API, not a general-purpose website scraper. One GET request returns an image or PDF. For an authorized page, this cURL request saves a WebP screenshot; see the ScreenshotNeo API documentation for parameters and response details.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
  • Cookie and consent banners are accepted before capture, and 60+ known consent platforms, newsletter popups, and chat widgets are removed; each step can be turned off.
  • Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers identify the page verdict and billing status.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots; every feature is available on every plan.

Sign up for 1,000 free screenshots a month—no card required.

Troubleshooting: diagnose the failure before changing settings

Symptom Likely category What to check next
Navigation throws a timeout Navigation or network Check the URL, connectivity, DNS, browser launch, and the failed-request log. Determine whether the document never loaded or whether the page keeps background requests open. Wait for the content selector rather than extending timeouts without limit.
The page loads but the selector never appears Rendering or selector mismatch Confirm the selector against the rendered page and whether the content is inside a frame or appears only after an interaction. Wait for the relevant selector or event. Browserless’s BrowserQL documentation notes that JavaScript-rendered pages may yield empty extraction unless the workflow waits for a selector or event.
The main response is unsuccessful Server response or access policy Log the status and inspect the page returned. A login requirement, rate limit, or denial needs the corresponding permitted access path; changing browser fingerprints is not a general fix.
Previously available content disappears between runs Session state Check whether the intended cookies or storage are missing or expired. Preserve only the authorized session state needed for continuity, or deliberately start with a clean context.
A challenge, CAPTCHA, or explicit block appears Access denial Stop automated attempts and contact the site, request permission, use an official API, or choose another source.
Changing browser settings makes the page less stable Configuration conflict Revert to the last known-good minimal configuration and change one task-relevant setting at a time. Browserless’s January 2026 article warns that excessive signal changes can increase risk or break layouts; this is vendor guidance, not a guarantee about any particular site.

When a managed browser service makes sense

A managed browser can be useful when you need hosted execution or an integration with an existing Puppeteer or Playwright workflow. Browserless documents managed stealth routes and BrowserQL integrations, and its documentation cautions that stealth routes can have unexpected effects on automation. These are vendor-described capabilities, not independent performance findings or a guarantee of access. Verify current feature availability, limits, pricing, and data-handling terms with the provider before choosing a service.

Compare local and hosted execution by operational control, session and debugging needs, deployment effort, data handling, workload cost, and provider-specific limits. No neutral performance comparison or current referral terms are established here.

Performance, reliability, and cost considerations

  • Wait on a meaningful condition. A relevant selector or state avoids both premature extraction and unnecessary fixed delays. A timeout is a diagnostic boundary, not proof that a page should be retried indefinitely.
  • Keep concurrency and retry behavior bounded. Respect the site’s published limits and any responses indicating rate limiting. Back off on transient failures only where retrying is permitted; stop on an explicit denial.
  • Make runs observable. Record the URL, navigation result, selector outcome, and relevant errors. Avoid retaining cookies or page data beyond the authorized task’s needs.
  • Budget the whole workflow. Local automation has browser, runtime, and maintenance costs; hosted execution adds provider-specific charges and limits. Compare those costs against the actual workload and required operations rather than assuming stealth changes improve throughput.
  • Expect maintenance. Sites alter markup and client-side behavior, while browser and framework APIs evolve. Pin and update dependencies deliberately, and revalidate selectors and session handling after changes.

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.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.