CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-2captcha-python

Python module for easy integration with 2Captcha API service to solve various types of captchas including reCAPTCHA, FunCaptcha, GeeTest, and many others

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

specialized-captchas.mddocs/

Specialized Captchas

Methods for solving specialized captcha systems including KeyCaptcha, Capy, Lemin, ATB, and various other proprietary captcha solutions.

Capabilities

KeyCaptcha

Solves KeyCaptcha puzzle challenges that require assembling key pieces.

def keycaptcha(self, s_s_c_user_id, s_s_c_session_id,
              s_s_c_web_server_sign, s_s_c_web_server_sign2, 
              url, **kwargs):
    """
    Solve KeyCaptcha challenges.
    
    Parameters:
    - s_s_c_user_id (str): Value of s_s_c_user_id parameter (required)
    - s_s_c_session_id (str): Value of s_s_c_session_id parameter (required)
    - s_s_c_web_server_sign (str): Value of s_s_c_web_server_sign parameter (required)
    - s_s_c_web_server_sign2 (str): Value of s_s_c_web_server_sign2 parameter (required)
    - url (str): Full URL where KeyCaptcha is located (required)
    - softId (int): Software developer ID
    - callback (str): Pingback URL for result notification
    - proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
    
    Returns:
    dict: {'captchaId': str, 'code': str} - code contains KeyCaptcha solution
    """

CapyPuzzle

Solves Capy Puzzle captcha challenges.

def capy(self, sitekey, url, **kwargs):
    """
    Solve Capy Puzzle captcha.
    
    Parameters:
    - sitekey (str): Value of sitekey parameter (required)
    - url (str): Full URL where Capy captcha is located (required)
    - api_server (str): API server URL if different from default
    - version (str): Capy version if specified
    - softId (int): Software developer ID
    - callback (str): Pingback URL for result notification
    - proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
    
    Returns:
    dict: {'captchaId': str, 'code': str} - code contains Capy solution
    """

Lemin Cropped Captcha

Solves Lemin Cropped Captcha challenges.

def lemin(self, captchaId, div_id, url, **kwargs):
    """
    Solve Lemin Cropped Captcha.
    
    Parameters:
    - captchaId (str): Value of captchaId parameter (required)
    - div_id (str): Value of div_id parameter (required)
    - url (str): Full URL where Lemin captcha is located (required)
    - api_server (str): API server URL if specified
    - softId (int): Software developer ID
    - callback (str): Pingback URL for result notification
    - proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
    
    Returns:
    dict: {'captchaId': str, 'code': str} - code contains Lemin solution
    """

atbCAPTCHA

Solves atbCAPTCHA challenges.

def atb_captcha(self, app_id, api_server, url, **kwargs):
    """
    Solve atbCAPTCHA challenges.
    
    Parameters:
    - app_id (str): Application ID for atbCAPTCHA (required)
    - api_server (str): atbCAPTCHA API server URL (required)
    - url (str): Full URL where atbCAPTCHA is located (required)
    - proxy (dict): Proxy configuration {'type': 'HTTPS', 'uri': 'login:pass@ip:port'}
    
    Returns:
    dict: {'captchaId': str, 'code': str} - code contains atbCAPTCHA solution
    """

Usage Examples

KeyCaptcha

from twocaptcha import TwoCaptcha

solver = TwoCaptcha('your_api_key')

# Extract KeyCaptcha parameters from the page
result = solver.keycaptcha(
    s_s_c_user_id='12345',
    s_s_c_session_id='session_id_value',
    s_s_c_web_server_sign='server_sign_value',
    s_s_c_web_server_sign2='server_sign2_value',
    url='https://example.com/keycaptcha-page'
)
print(f"KeyCaptcha solution: {result['code']}")

# With proxy support
result = solver.keycaptcha(
    s_s_c_user_id='12345',
    s_s_c_session_id='session_id',
    s_s_c_web_server_sign='sign1',
    s_s_c_web_server_sign2='sign2',
    url='https://secure-site.com',
    proxy={'type': 'HTTPS', 'uri': 'user:pass@proxy.com:8080'}
)
print(f"Solution: {result['code']}")

Capy Puzzle

from twocaptcha import TwoCaptcha

solver = TwoCaptcha('your_api_key')

# Basic Capy captcha
result = solver.capy(
    sitekey='capy_site_key',
    url='https://example.com/capy-form'
)
print(f"Capy solution: {result['code']}")

# With custom API server and version
result = solver.capy(
    sitekey='capy_site_key',
    url='https://example.com/form',
    api_server='https://api.capy.me',
    version='1.0'
)
print(f"Solution: {result['code']}")

Lemin Cropped Captcha

from twocaptcha import TwoCaptcha

solver = TwoCaptcha('your_api_key')

# Solve Lemin captcha
result = solver.lemin(
    captchaId='lemin_captchaId',
    div_id='lemin_div_id',
    url='https://example.com/lemin-captcha'
)
print(f"Lemin solution: {result['code']}")

# With custom API server
result = solver.lemin(
    captchaId='captcha_123',
    div_id='div_456',
    url='https://site.com',
    api_server='https://api.lemin.me'
)
print(f"Solution: {result['code']}")

atbCAPTCHA

from twocaptcha import TwoCaptcha

solver = TwoCaptcha('your_api_key')

# Solve atbCAPTCHA
result = solver.atb_captcha(
    app_id='atb_app_id',
    api_server='https://api.atb-captcha.com',
    url='https://example.com/atb-form'
)
print(f"atbCAPTCHA solution: {result['code']}")

# With proxy
result = solver.atb_captcha(
    app_id='app_123',
    api_server='https://api.atb.com',
    url='https://secure-form.com',
    proxy={'type': 'HTTPS', 'uri': 'proxy_user:proxy_pass@proxy.com:3128'}
)
print(f"Solution: {result['code']}")

Error Handling for Specialized Captchas

from twocaptcha import TwoCaptcha, ValidationException, ApiException

solver = TwoCaptcha('your_api_key')

try:
    # Missing required parameter
    result = solver.keycaptcha(
        s_s_c_user_id='123',
        s_s_c_session_id='',  # Empty required parameter
        s_s_c_web_server_sign='sign1',
        s_s_c_web_server_sign2='sign2',
        url='https://example.com'
    )
except ValidationException as e:
    print(f"Validation error: {e}")

try:
    # Invalid captcha parameters
    result = solver.capy(
        sitekey='invalid_key',
        url='https://example.com'
    )
except ApiException as e:
    print(f"API error: {e}")

Integration Example

from twocaptcha import TwoCaptcha
import requests
from selenium import webdriver

# Setup
solver = TwoCaptcha('your_api_key')
driver = webdriver.Chrome()

try:
    # Navigate to page with KeyCaptcha
    driver.get('https://example.com/keycaptcha-form')
    
    # Extract KeyCaptcha parameters from page
    user_id = driver.execute_script("return window.s_s_c_user_id;")
    session_id = driver.execute_script("return window.s_s_c_session_id;")
    sign1 = driver.execute_script("return window.s_s_c_web_server_sign;")
    sign2 = driver.execute_script("return window.s_s_c_web_server_sign2;")
    
    # Solve captcha
    result = solver.keycaptcha(
        s_s_c_user_id=user_id,
        s_s_c_session_id=session_id,
        s_s_c_web_server_sign=sign1,
        s_s_c_web_server_sign2=sign2,
        url=driver.current_url
    )
    
    # Use solution in form
    driver.execute_script(f"document.keycaptcha_response = '{result['code']}';")
    print(f"KeyCaptcha solved: {result['code']}")
    
finally:
    driver.quit()

Install with Tessl CLI

npx tessl i tessl/pypi-2captcha-python

docs

audio-text-captchas.md

cloud-captchas.md

core-solver.md

emerging-captchas.md

image-captchas.md

index.md

interactive-captchas.md

specialized-captchas.md

tile.json