Skip to main content

A wrapper to make python selenium stealthy.

Project description

stealthenium Python Versions

A python package to prevent selenium detection. This programme is trying to make python selenium more stealthy. As of now August 2024 stealthenium only supports Chrome and Remote WebDriver.

This is a fork of selenium-stealth developed by @diprajpatra and has came to be because it is no longer maintained (last commit November 5 2020 as of August 23 2024). It can be seen as a re-implementation of JavaScript puppeteer-extra-plugin-stealth developed by @berstend.

Features

  • passes all public bot tests.

  • bypass Cloudflare and other bot detection systems.

  • maintains reasonable reCAPTCHA v3 score

Install

stealthenium is available on PyPI you can install with pip.

$ pip install stealthenium

Usage

from selenium import webdriver
from stealthenium 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,
    service=webdriver.ChromeService(r"\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/96.0.4664.110 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 - bad)

Without stealthenium

headless
headful

With stealthenium

headless
headful

License

Copyright © 2024, markmelnic. Released under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stealthenium-1.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

stealthenium-1.1.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file stealthenium-1.1.0.tar.gz.

File metadata

  • Download URL: stealthenium-1.1.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for stealthenium-1.1.0.tar.gz
Algorithm Hash digest
SHA256 04b098b7c1549202c9d14cf11be378e9461be2b36f7f1f75b3b021cf14be4035
MD5 a32383454ddc5778adf46ee49fe37e28
BLAKE2b-256 0aff0e592fcbc6943eea19dbad4729d370744c18f33d3ee9cdab6616340f15fb

See more details on using hashes here.

File details

Details for the file stealthenium-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: stealthenium-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for stealthenium-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 092613a0d512c91dd8d3692f8b2d4f43eea3d8a27bc226ef39c4a6cd2403600b
MD5 650b7bd5785f6becbd766ead13ba2eef
BLAKE2b-256 94e1b6d2d3fefc44a40922c325a0df5720f0fb82d0e3be91c144596ddac53b11

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page