All Projects → maximedrn → hcaptcha-solver-python-selenium

maximedrn / hcaptcha-solver-python-selenium

Licence: Apache-2.0 license
hCaptcha solver and bypasser for Python Selenium. Simple website to try to solve hCaptcha.

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to hcaptcha-solver-python-selenium

Undetected Chromedriver
Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
Stars: ✭ 365 (+1040.63%)
Mutual labels:  webdriver, captcha, selenium
basic-selenium-project
an example selenium test project
Stars: ✭ 55 (+71.88%)
Mutual labels:  webdriver, selenium
Captcha-Tools
All-in-one Python (And now Go!) module to help solve captchas with Capmonster, 2captcha and Anticaptcha API's!
Stars: ✭ 23 (-28.12%)
Mutual labels:  captcha, hcaptcha
pystest
WEB UI自动化测试框架,selenium结合python,测试人员不需要会代码,只需要写配置即可实现,并且方便懂代码的测试人员扩展
Stars: ✭ 24 (-25%)
Mutual labels:  webdriver, selenium
google-meet-bot
Bot for scheduling and entering google meet sessions automatically
Stars: ✭ 33 (+3.13%)
Mutual labels:  webdriver, selenium
phoenix.webui.framework
基于WebDriver的WebUI自动化测试框架
Stars: ✭ 118 (+268.75%)
Mutual labels:  webdriver, selenium
SeleniumTDD
A Selenium TDD framework that incorporates key features of Selenium and TestNG which can be used to create web-based automation scripts.
Stars: ✭ 23 (-28.12%)
Mutual labels:  webdriver, selenium
Selenoid Ui
Graphical user interface for Selenoid project
Stars: ✭ 237 (+640.63%)
Mutual labels:  webdriver, selenium
selenium-openapi
The missing Selenium OpenAPI spec
Stars: ✭ 25 (-21.87%)
Mutual labels:  webdriver, selenium
callisto
Callisto is an open-source Kubernetes-native implementation of Selenium Grid.
Stars: ✭ 83 (+159.38%)
Mutual labels:  webdriver, selenium
2captcha-go
Golang Module for easy integration with the API of 2captcha captcha solving service to bypass recaptcha, hcaptcha, funcaptcha, geetest and solve any other captchas.
Stars: ✭ 31 (-3.12%)
Mutual labels:  captcha, hcaptcha
dcat-auth-captcha
Sliding captcha for dcat-admin auth / dcat-admin登陆 滑动验证插件 多平台支持
Stars: ✭ 38 (+18.75%)
Mutual labels:  captcha, hcaptcha
Selion
Enabling Test Automation in Java
Stars: ✭ 252 (+687.5%)
Mutual labels:  webdriver, selenium
RARBG-scraper
With Selenium headless browsing and CAPTCHA solving
Stars: ✭ 38 (+18.75%)
Mutual labels:  captcha, selenium
Pytest Selenium
Plugin for running Selenium with pytest
Stars: ✭ 246 (+668.75%)
Mutual labels:  webdriver, selenium
spydriver
🕵️ Lightweight utility to intercept WebDriver and WebElement method calls.
Stars: ✭ 24 (-25%)
Mutual labels:  webdriver, selenium
opensea automatic uploader
(Bypass reCAPTCHAs) A Selenium Python bot to automatically and bulky upload and list your NFTs on OpenSea (all metadata integrated - Ethereum and Polygon supported); reCAPTCHA solver & bypasser included.
Stars: ✭ 205 (+540.63%)
Mutual labels:  captcha, selenium
Selenium Python Helium
Selenium-python but lighter: Helium is the best Python library for web automation.
Stars: ✭ 2,732 (+8437.5%)
Mutual labels:  webdriver, selenium
Cdp4j
cdp4j - Chrome DevTools Protocol for Java
Stars: ✭ 232 (+625%)
Mutual labels:  webdriver, selenium
nightwatch101
使用 Nightwatch 實現 End-to-End Testing ★
Stars: ✭ 42 (+31.25%)
Mutual labels:  webdriver, selenium

hCaptcha solver for Python Selenium.

Many thanks to engageub for his hCaptcha solver userscript.
This script is solely intended for the use of educational purposes only and not to abuse any website.
The solving speed depends on your PC's compute power and Internet connection.

Table of contents:

Instructions:

  • Download this repository or clone it:
git clone https://github.com/maximedrn/hcaptcha-solver-python-selenium.git
  • It requires Python 3.7 or a newest version.
  • Install pip to be able to have needed Python modules.
  • Download and install Google Chrome.
  • Download the ChromeDriver executable that is compatible with the actual version of your Google Chrome browser and your OS (Operating System). Refer to: What version of Google Chrome do I have?
  • Extract the executable from the ZIP file and copy/paste it in the assets/ folder of the repository.
  • Open a command prompt in repository folder and type:
pip install -r requirements.txt
  • Then type to see a demonstration:
python main.py

This code can be implemented in any project. You just have to had the hCaptcha class without the demonstration() method in your Python project repository. Then init the class in your Python code. You should have something like this:

hcaptcha-solver.py

"""
@author: Maxime.

Github: https://github.com/maximedrn
Demonstration website: https://maximedrn.github.io/hcaptcha-test/
Version: 1.1
"""

# Colorama module: pip install colorama
from colorama import init, Fore, Style

# Selenium module imports: pip install selenium
from selenium import webdriver
from selenium.common.exceptions import TimeoutException as TE
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait as WDW
from selenium.webdriver.common.by import By

# Python default import.
import sys
import os


"""Colorama module constants."""
init(convert=True)  # Init colorama module.
red = Fore.RED  # Red color.
green = Fore.GREEN  # Green color.
yellow = Fore.YELLOW  # Yellow color.
reset = Style.RESET_ALL  # Reset color attribute.


class hCaptcha:
    """Main class of the hCaptcha solver."""

    def __init__(self) -> None:
        """Set path of used file and start webdriver."""
        self.webdriver_path = 'assets/chromedriver.exe'
        self.extension_path = 'assets/Tampermonkey.crx'
        self.driver = self.webdriver()  # Start new webdriver.

    def webdriver(self):
        """Start webdriver and return state of it."""
        options = webdriver.ChromeOptions()  # Configure options for Chrome.
        options.add_extension(self.extension_path)  # Add extension.
        options.add_argument('--lang=en')  # Set webdriver language to English.
        # options.add_argument("headless")  # Headless ChromeDriver.
        options.add_argument('log-level=3')  # No logs is printed.
        options.add_argument('--mute-audio')  # Audio is muted.
        options.add_argument("--enable-webgl-draft-extensions")
        options.add_argument("--ignore-gpu-blocklist")
        driver = webdriver.Chrome(self.webdriver_path, options=options)
        driver.maximize_window()  # Maximize window to reach all elements.
        return driver

    def element_clickable(self, element: str) -> None:
        """Click on element if it's clickable using Selenium."""
        WDW(self.driver, 5).until(EC.element_to_be_clickable(
            (By.XPATH, element))).click()

    def element_visible(self, element: str):
        """Check if element is visible using Selenium."""
        return WDW(self.driver, 20).until(EC.visibility_of_element_located(
            (By.XPATH, element)))

    def window_handles(self, window_number: int) -> None:
        """Check for window handles and wait until a specific tab is opened."""
        WDW(self.driver, 30).until(lambda _: len(
            self.driver.window_handles) == window_number + 1)
        # Switch to asked tab.
        self.driver.switch_to.window(self.driver.window_handles[window_number])

    def download_userscript(self) -> None:
        """Download the hCaptcha solver userscript."""
        try:
            print('Installing the hCaptcha solver userscript.', end=' ')
            self.window_handles(1)  # Wait that Tampermonkey tab loads.
            self.driver.get('https://greasyfork.org/en/scripts/425854-hcaptcha'
                            '-solver-automatically-solves-hcaptcha-in-browser')
            # Click on "Install" Greasy Fork button.
            self.element_clickable('//*[@id="install-area"]/a[1]')
            # Click on "Install" Tampermonkey button.
            self.window_handles(2)  # Switch on Tampermonkey install tab.
            self.element_clickable('//*[@value="Install"]')
            self.window_handles(1)  # Switch to Greasy Fork tab.
            self.driver.close()  # Close this tab.
            self.window_handles(0)  # Switch to main tab.
            print(f'{green}Installed.{reset}')
        except TE:
            sys.exit(f'{red}Failed.{reset}')

def cls() -> None:
    """Clear console function."""
    # Clear console for Windows using 'cls' and Linux & Mac using 'clear'.
    os.system('cls' if os.name == 'nt' else 'clear')
    
if __name__ == '__main__':

    cls()  # Clear console.

    print('hCaptcha Solver'
          f'\n{green}Made by Maxime.'
          f'\n@Github: https://github.com/maximedrn{reset}')

your-script.py

from hcaptcha-solver import hCaptcha

# Your code.
# ...

if __name__ == '__main__':
    hcaptcha = hCaptcha()  # Init hCaptcha class.
    hcaptcha.download_userscript()  # Download the hCaptcha solver userscript.

Demonstration:

Demonstration GIF.

Simple website to try to solve hCaptcha.

  • Open a new tab and go to the website hCaptcha test.
  • Website preview:

Website preview

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].