Hi ππ
In this post, I will share with you How to bypass hCaptcha using Python and 2captcha.
Step 1
Create an account in 2captcha from here
Step 2
2captcha offers a variety of deposit options, making the process easier for users. A minimum deposit of $3 is required.
Step 3
Install 2captcha-python
pip install 2captcha-python
Step 4
Go to you 2captcha account and make sure that the type of your account is developer
Copy your API key from your account dashboard or enterpage
Step 5
Create a .env
file to store your API key, or you can directly put it in your code as per your preference. In this example, I will create the .env
file.
from selenium import webdriver
from selenium.webdriver.common.by import By
from dotenv import load_dotenv
# https://pypi.org/project/2captcha-python/
from twocaptcha import TwoCaptcha
import time
import sys
import os
# https://github.com/2captcha/2captcha-python
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
url = 'https://accounts.hcaptcha.com/demo'
driver = webdriver.Chrome()
driver.get(url=url)
time.sleep(2)
site_key = driver.find_element(
by = By.XPATH,
value = '//*[@id="hcaptcha-demo"]').get_attribute('data-sitekey')
load_dotenv()
# create account in 2captcha from here : https://bit.ly/3MkkuPJ
# make deposit at least 3$
# https://2captcha.com/pay
# create env file or you can put your API key direct in TwoCaptcha function
api_key = os.getenv('APIKEY_2CAPTCHA', 'YOUR_API_KEY')
solver = TwoCaptcha(api_key)
try:
result = solver.hcaptcha(
sitekey=site_key,
url=url,
)
code = result['code']
print(code)
driver.execute_script(f"document.getElementsByName('h-captcha-response')[0].innerHTML = '{code}'")
# submit
driver.find_element(by = By.ID, value = 'hcaptcha-demo-submit').click()
except Exception as e:
sys.exit(e)
input()
Top comments (0)