Playwright Stealth is a Python package designed to make Playwright browser automation sessions less detectable by anti-bot systems. It achieves this by patching various browser fingerprints and automation-specific properties. Actively maintained, it currently stands at version 2.0.3 and utilizes a modern context-manager API for integration with Playwright.
pip install playwright-stealthVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the recommended asynchronous usage of `playwright-stealth` with Playwright's context manager. It launches a stealthy Chromium browser, checks the `navigator.webdriver` property (which should be `False` or undefined when stealth is applied), and navigates to a sample page. Remember to install Playwright browser binaries via `playwright install chromium` first.
Migrate your code to use the `Stealth` class with its context manager (`async with Stealth().use_async(async_playwright())`) or `apply_stealth_async(context)` method.
For highly protected websites, consider combining `playwright-stealth` with proxy rotation (especially residential proxies), realistic user behavior simulation (random delays, mouse movements), and session management.
After installing `playwright-stealth`, run `playwright install` (or `playwright install chromium` for a specific browser) in your environment to download the necessary browser binaries.
Implement robust infrastructure-level solutions for scaling, such as distributed proxies, diverse user-agent rotation, dynamic header management, and careful pacing of requests to mimic human browsing more closely.
Install the package using 'pip install playwright-stealth'.
Import the correct function: 'from playwright_stealth import stealth_sync' or 'from playwright_stealth import stealth_async'.
Ensure that Playwright is correctly installed and imported: 'from playwright.sync_api import sync_playwright'.
Update your code to use the modern `Stealth` class and its context manager API. For asynchronous operations, use `from playwright_stealth import Stealth; async with Stealth().use_async(async_playwright()) as p: ...`.
Use `from playwright_stealth import add_stealth_sync` and then call `add_stealth_sync(page)` or `add_stealth_sync(context)`.