Skip to main content

Trying to make python selenium more stealthy.

Project description

selenium-stealth Build Status

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/Chromium.

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.

Download files

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

Source Distribution

selenium_stealth_fork-1.0.8.tar.gz (23.2 kB view details)

Uploaded Source

File details

Details for the file selenium_stealth_fork-1.0.8.tar.gz.

File metadata

  • Download URL: selenium_stealth_fork-1.0.8.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for selenium_stealth_fork-1.0.8.tar.gz
Algorithm Hash digest
SHA256 58dd579cce7ec315e6eb218f72453f802079c451f970ffe8fc55dca0cc862c61
MD5 7a52861b0770a5c75c954d26dc764474
BLAKE2b-256 2cc6ca5d9a455bdc0dc86b03b973c4786e9e8818e127d3eaca563f263de788ce

See more details on using hashes here.

Supported by

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