{"id":3214,"library":"playwright-stealth","title":"Playwright Stealth","description":"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.","status":"active","version":"2.0.3","language":"python","source_language":"en","source_url":"https://github.com/Mattwmaster58/playwright_stealth","tags":["playwright","stealth","scraping","automation","anti-bot","web scraping"],"install":[{"cmd":"pip install playwright-stealth","lang":"bash","label":"Install package"},{"cmd":"playwright install chromium","lang":"bash","label":"Install Playwright browser binaries (required)"}],"dependencies":[{"reason":"playwright-stealth patches the underlying Playwright browser instance, thus Playwright is a core dependency.","package":"playwright","optional":false}],"imports":[{"symbol":"Stealth","correct":"from playwright_stealth import Stealth"},{"note":"These functions were part of the v1.x API and are deprecated. The v2.x API uses a context manager approach.","wrong":"from playwright_stealth import stealth_async","symbol":"stealth_async / stealth_sync"}],"quickstart":{"code":"import asyncio\nimport os\nfrom playwright.async_api import async_playwright\nfrom playwright_stealth import Stealth\n\nasync def main():\n    async with Stealth().use_async(async_playwright()) as p:\n        browser = await p.chromium.launch(headless=True)\n        page = await browser.new_page()\n        \n        # Example: Go to a test page and check navigator.webdriver property\n        # An actual stealth check would involve visiting sannysoft.com or similar\n        await page.goto(\"https://www.google.com\")\n        is_webdriver = await page.evaluate(\"navigator.webdriver\")\n        print(f\"Is navigator.webdriver set? {is_webdriver}\")\n\n        # Navigate to another page\n        await page.goto(\"https://web-scraping.dev/products\")\n        title = await page.title()\n        print(f\"Page title: {title}\")\n        \n        await browser.close()\n\nif __name__ == \"__main__\":\n    asyncio.run(main())","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"The API for `playwright-stealth` underwent a breaking change from v1.x to v2.x. Older patterns like `stealth_async(page)` or `stealth_sync(page)` are no longer supported. The current recommended approach uses a `Stealth().use_async(async_playwright())` context manager or `stealth.apply_stealth_async(context)` method for explicit control.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"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.","message":"While `playwright-stealth` helps bypass many common bot detection methods by patching browser fingerprints (e.g., `navigator.webdriver`, User-Agent), it does not provide complete immunity against advanced anti-bot systems. These systems might analyze IP reputation, TLS fingerprints, behavioral patterns, and other infrastructure-level signals, which `playwright-stealth` does not address.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After installing `playwright-stealth`, run `playwright install` (or `playwright install chromium` for a specific browser) in your environment to download the necessary browser binaries.","message":"The `playwright` library (on which `playwright-stealth` depends) no longer automatically downloads browser binaries (Chromium, Firefox, WebKit) when installed via `pip` since version 1.38+. If you forget to install the browsers, `playwright-stealth` will fail to launch a browser.","severity":"gotcha","affected_versions":"playwright>=1.38.0"},{"fix":"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.","message":"Stealth techniques that work for small-scale testing often fail when scaled up. Consistent browser fingerprints, repeated access patterns from the same IP, and rapid requests can lead to detection and blocking by anti-bot services, even with stealth plugins.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'2.0.3':43 'achiev':24 'activ':36 'anti':20,61 'anti-bot':19,60 'api':51 'autom':14,33,59 'automation-specif':32 'bot':21,62 'browser':13,29 'context':49 'context-manag':48 'current':39 'design':9 'detect':17 'fingerprint':30 'integr':53 'less':16 'maintain':37 'make':11 'manag':50 'modern':47 'packag':8 'patch':27 'playwright':1,3,12,55,56 'properti':35 'python':7 'scrape':58,64 'session':15 'specif':34 'stand':40 'stealth':2,4,57 'system':22 'util':45 'various':28 'version':42 'web':63","created_at":"2026-04-11T09:25:54.498202+00:00","updated_at":"2026-04-17T14:15:20.484257+00:00","problems":[{"fix":"Install the package using 'pip install playwright-stealth'.","cause":"The 'playwright-stealth' package is not installed or not properly installed.","error":"ModuleNotFoundError: No module named 'playwright_stealth'"},{"fix":"Import the correct function: 'from playwright_stealth import stealth_sync' or 'from playwright_stealth import stealth_async'.","cause":"The 'playwright_stealth' package does not contain a 'Stealth' class; it provides 'stealth_sync' and 'stealth_async' functions.","error":"ImportError: cannot import name 'Stealth' from 'playwright_stealth'"},{"fix":"Ensure that Playwright is correctly installed and imported: 'from playwright.sync_api import sync_playwright'.","cause":"The 'playwright' module is not properly initialized or imported.","error":"AttributeError: module 'playwright' has no attribute 'chromium'"},{"fix":"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: ...`.","cause":"This error arises when attempting to import the `stealth_async` (or `stealth_sync`) function, which was part of the v1.x API, but `playwright-stealth` version 2.x or newer is installed. The v2.x+ API utilizes a `Stealth` class with a context manager.","error":"ImportError: cannot import name 'stealth_async' from 'playwright_stealth'"},{"fix":"Use `from playwright_stealth import add_stealth_sync` and then call `add_stealth_sync(page)` or `add_stealth_sync(context)`.","cause":"The direct import of `stealth_sync` was removed in favor of `add_stealth_sync` in recent versions (>=1.0.0) of `playwright-stealth`.","error":"ImportError: cannot import name 'stealth_sync' from 'playwright_stealth'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"2.0.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/Mattwmaster58/playwright_stealth","docs":null,"changelog":"https://github.com/Mattwmaster58/playwright_stealth/raw/main/CHANGELOG.md","pypi":"https://pypi.org/project/playwright-stealth/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}