Skip to main content

Trying to make python selenium more stealthy.

Project description

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:

  • :white_check_mark: selenium-stealth with stealth passes all public bot tests.

  • :white_check_mark: With selenium-stealth selenium can do google account login.

  • :white_check_mark: 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.

Project details


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-1.0.3.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

selenium_stealth-1.0.3-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file selenium-stealth-1.0.3.tar.gz.

File metadata

  • Download URL: selenium-stealth-1.0.3.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for selenium-stealth-1.0.3.tar.gz
Algorithm Hash digest
SHA256 9503c4cf4dd1719da46fc811c42db0561b4e10afe5cbf4efcbeada5c37453d6f
MD5 913d2061c7664177e495ffd15461c254
BLAKE2b-256 e71ac6ad4ec03da915884e6d6e4947838514f0647ff395fcbac6a9533ef8afb3

See more details on using hashes here.

File details

Details for the file selenium_stealth-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: selenium_stealth-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for selenium_stealth-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c98d13d9fb7e4933ac860868d1ea25e82479379e4fd62468278fd8d9d98097b2
MD5 5dfe2ad481e6ac33673587e8589fbefb
BLAKE2b-256 8045d4d27dd5c077fcb86d50b1714cdf03a8a9c0738257b4ad575fea11b3cb5a

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