Skip to main content

playwright_stealth

Transplanted from puppeteer-extra-plugin-stealth, Not perfect. Forked from playwright_stealth and re-released.

Install

$ pip install playwright-stealth2

Usage

Default stealth

sync

from playwright.sync_api import sync_playwright
from playwright_stealth import stealth_sync

with sync_playwright() as p:
    for browser_type in [p.chromium, p.firefox, p.webkit]:
        browser = browser_type.launch(headless=False)
        page = browser.new_page()
        stealth_sync(page)
        page.goto('https://bot.sannysoft.com/')
        page.screenshot(path=f'example-{browser_type.name}.png', full_page=True)
        browser.close()

async

# -*- coding: utf-8 -*-
import asyncio
from playwright.async_api import async_playwright
from playwright_stealth import stealth_async

async def main():
    async with async_playwright() as p:
        for browser_type in [p.chromium, p.firefox, p.webkit]:
            browser = await browser_type.launch(headless=False)
            page = await browser.new_page()
            await stealth_async(page)
            await page.goto('https://bot.sannysoft.com/')
            await page.screenshot(path=f'example-{browser_type.name}.png', full_page=True)
            await browser.close()

asyncio.run(main())

Desired stealth argument (as a mobile device)

sync

from playwright.sync_api import sync_playwright
from playwright_stealth import stealth_sync, StealthConfig

with sync_playwright() as p:
    for browser_type in [p.chromium, p.firefox, p.webkit]:
        browser = browser_type.launch(headless=False)
        context = browser.new_context(**p.devices["Pixel 7"])
        page = context.new_page()
        # Setting desired values for navigator properties
        stealth_config = StealthConfig(
            languages = ['en-US', 'en'],
            navigator_plugins = False, # Mimicking real mobile device
            navigator_hardware_concurrency = 8,
            # nav_vendor = "", # Use only if you need to set empty string value to mimicking Firefox browser
            nav_platform= 'Linux armv81',
            vendor = 'Google Inc. (Qualcomm)',
            renderer = 'ANGLE (Qualcomm, Adreno (TM) 640, OpenGL ES 3.2)',
        )
        stealth_sync(page, stealth_config)
        page.goto('https://bot.sannysoft.com/')
        page.screenshot(path=f'example-{browser_type.name}.png', full_page=True)
        browser.close()

async

# -*- coding: utf-8 -*-
import asyncio
from playwright.async_api import async_playwright
from playwright_stealth import stealth_async, StealthConfig

async def main():
    async with async_playwright() as p:
        for browser_type in [p.chromium, p.firefox, p.webkit]:
            browser = await browser_type.launch(headless=False)
            context = await browser.new_context(**p.devices["Pixel 7"])
            page = await context.new_page()
            # Setting desired values for navigator properties
            stealth_config = StealthConfig(
                languages = ['en-US', 'en'],
                navigator_plugins = False, # Mimicking real mobile device
                navigator_hardware_concurrency = 8,
                # nav_vendor = "", # Use only if you need to set empty string value to mimicking Firefox browser
                nav_platform= 'Linux armv81',
                vendor = 'Google Inc. (Qualcomm)',
                renderer = 'ANGLE (Qualcomm, Adreno (TM) 640, OpenGL ES 3.2)',
            )
            await stealth_async(page, stealth_config)
            await page.goto('https://bot.sannysoft.com/')
            await page.screenshot(path=f'example-{browser_type.name}.png')
            await browser.close()

asyncio.run(main())

Test results

Playwright with stealth(no passed argument)

playwright with stealth

Playwright without stealth

playwright without stealth

Playwright with stealth(with passed argument) but as a mobile device

NB: Mobile device have no plugin unlike desktop playwright stealth with specified arguments

Metadata

Release files for playwright-sm 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for playwright-sm 0.0.1
File Size Uploaded Provenance Actions
playwright_sm-0.0.1.tar.gz 21.3 kB Without provenance Details for playwright_sm-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for playwright-sm 0.0.1
File Interpreter ABI Platform Actions
playwright_sm-0.0.1-py3-none-any.whl Python 3 none any Details for playwright_sm-0.0.1-py3-none-any.whl

Total release size: 49.5 kB

Release files / playwright_sm-0.0.1.tar.gz

Download URL playwright_sm-0.0.1.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7c418e7fdf481006fa9128357dc0c992b39ed0b4547f408dfe38198af8602238
BLAKE2b-256 checksum
How to use checksums
75642070bebe07ceac8ecb2a756073e4ba181b91412b14b1089c57e0407fd4f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Release files / playwright_sm-0.0.1-py3-none-any.whl

Download URL playwright_sm-0.0.1-py3-none-any.whl
Size 28.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fbf20136350402f04cb2c38e6abdb8052627919544e363e980449a03bf20f6d4
BLAKE2b-256 checksum
How to use checksums
15cb28fb511e0f42b7914d0489ae23d6c998f7c9c0624e4e855557eaba035b6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.8

Security for playwright-sm 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page