How to bypass CAPTCHA using Python#

About CAPTCHA#

CAPTCHA is the abbreviation of "Completely Automated Public Turing test to tell Computers and Humans Apart". It is a Test used to confirm whether a website visitor is a real person and not an automated program (such as a robot or malware). CAPTCHA is usually presented to users in the form of an image, requiring users to enter the text or numbers they see in a text box. This Test uses humans' ability to recognize images and text to ensure the security of the website and prevent malicious attacks and automated operations.

Environmental preparation#

You can install NextCaptcha Python SDK using pip:
pip install nextcaptcha-python

usage#

To start using the NextCaptcha Python SDK, you first need to obtain the API key (clientKey) from the NextCaptcha dashboard. You can then create a NextCaptchaAPI instance:
from nextcaptcha import NextCaptchaAPI
 
api = NextCaptchaAPI(client_key="YOUR_CLIENT_KEY")
Now you can use API Object to solve type types of Captcha. To solve the reCAPTCHA v2 challenge, use the recaptchav2 method:
result = api.recaptchav2(website_url="https://example.com", website_key="SITE_KEY")
Resolving reCAPTCHA v2 Enterprise To resolve reCAPTCHA v2 Enterprise issues, use the recaptchav2enterprise method:
result = api.recaptchav2enterprise(website_url="https://example.com", website_key="SITE_KEY")
Solving reCAPTCHA v3 To solve reCAPTCHA v3 challenges, use the recaptchav3 method:
result = api.recaptchav3(website_url="https://example.com", website_key="SITE_KEY")
Solving reCAPTCHA Mobile To solve the reCAPTCHA Mobile challenge, use the recaptcha_mobile method:
result = api.recaptcha_mobile(app_key="APP_KEY")
Solving hCaptcha To solve hCaptcha challenges, use the hcaptcha method:
result = api.hcaptcha(website_url="https://example.com", website_key="SITE_KEY")
Resolving hCaptcha Enterprise To resolve hCaptcha Enterprise challenges, use the hcaptcha_enterprise method:
result = api.hcaptcha_enterprise(website_url="https://example.com", website_key="SITE_KEY")
Solving FunCaptcha To solve the FunCaptcha challenge, use the funcaptcha method:
result = api.funcaptcha(website_public_key="WEBSITE_PUBLIC_KEY")
Checking Account Balance To check your NextCaptcha account balance, use the get_balance method:
balance = api.get_balance()
print(f"Account balance: {balance}")
Here is a complete example of using the NextCaptcha Python SDK to solve the reCAPTCHA v2 challenge:
from nextcaptcha import NextCaptchaAPI
 
CLIENT_KEY = "YOUR_CLIENT_KEY"
WEBSITE_URL = "https://example.com"
WEBSITE_KEY = "SITE_KEY"
 
api = NextCaptchaAPI(client_key=CLIENT_KEY)
result = api.recaptchav2(website_url=WEBSITE_URL, website_key=WEBSITE_KEY)
 
if result["status"] == "ready":
    print(f"reCAPTCHA solved: {result['solution']}")
else:
    print(f"Failed to solve reCAPTCHA: {result['error']}")

Error handling#

If there is an error in the Captcha, the SDK will return a dictionary containing error information. You can check the status field to determine whether the request was successful. If the status is "Ready", the Captcha has been successfully solved and the Plan will be available in the Plan field. If the status is "Failed", the error field will contain a Description of the error