Skip to main content

selenium-stealth

A python package selenium-stealth to prevent detection. This programme is trying to make python selenium more stealthy.

As of now selenium-stealth only support Selenium Chrome.

After using selenium-stealth you can prevent almost all selenium detections. There is a lot of guides on stackoverflow on How to prevent selenium detection but I can not find a single python package for it so I am just creating one after all we can't let the cats win. It can be seen as a re-implementation of JavaScript puppeteer-extra-plugin-stealth developed by @berstend.

Features that currently selenium-stealth can offer:

  • ✔️ selenium-stealth with stealth passes all public bot tests.

  • ✔️ With selenium-stealth selenium can do google account login.

  • ✔️ selenium-stealth help with maintaining a normal reCAPTCHA v3 score

Donations

If you find this package useful and would like to support its continued development, you can donate here. Thank you for your support.

Donate Via PayPal

Install

Selenium-stealth is available on PyPI you can install with pip.

$ pip install selenium-stealth

Usage

from selenium import webdriver
from selenium_stealth import stealth
import time

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")

# options.add_argument("--headless")

options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
driver = webdriver.Chrome(options=options, executable_path=r"C:\Users\DIPRAJ\Programming\adclick_bot\chromedriver.exe")

stealth(driver,
        languages=["en-US", "en"],
        vendor="Google Inc.",
        platform="Win32",
        webgl_vendor="Intel Inc.",
        renderer="Intel Iris OpenGL Engine",
        fix_hairline=True,
        )

url = "https://bot.sannysoft.com/"
driver.get(url)
time.sleep(5)
driver.quit()

Args

stealth(
    driver: Driver,
    user_agent: str = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.53 Safari/537.36',
    languages: [str] = ["en-US", "en"],
    vendor: str = "Google Inc.",
    platform: str = "Win32",
    webgl_vendor: str = "Intel Inc.",
    renderer: str = "Intel Iris OpenGL Engine",
    fix_hairline: bool = False,
    run_on_insecure_origins: bool = False,
)

Test results (red is bad)

Selenium without selenium-stealth 😢

headless
headful

Selenium with selenium-stealth 💯

headless
headful

License

Copyright © 2020, diprajpatra. Released under the MIT License.

Metadata

Release files for selenium-stealth 1.0.4

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

Source distribution (sdist)

Source distribution for selenium-stealth 1.0.4
File Size Uploaded
selenium-stealth-1.0.4.tar.gz 20.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for selenium-stealth 1.0.4
File Interpreter ABI Platform
selenium_stealth-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 52.5 kB

Release files / selenium-stealth-1.0.4.tar.gz

Download URL selenium-stealth-1.0.4.tar.gz
Size 20.7 kB
Tags Source
SHA-256 checksum
How to use checksums
18d98f1da55b4c5ed9930e7604140df228c4d4bd424a9d3df923aa57e5245437
BLAKE2b-256 checksum
How to use checksums
46a834ad782c3f1ecd435f2003676edb309760c2e6154b6209285d5e2dee9bd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.8

Release files / selenium_stealth-1.0.4-py3-none-any.whl

Download URL selenium_stealth-1.0.4-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5a54f85cef81d25bc46f259c5d0818118dbc272c1b3a7b2c84a33f5780870651
BLAKE2b-256 checksum
How to use checksums
29873987fa63b7e01fb85c74e32781927754fca34329ebf226289114da8de89b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.8

Release history Release notifications | RSS feed

1.0.6

1 release file

1.0.5

2 release files

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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