Skip to content

providers

providers

__all__ = ['Solver2CaptchaService'] module-attribute

Solver2CaptchaService

Bases: CaptchaService

Service for solving captchas using 2Captcha.

__init__(credentials: dict) -> None

Initializes the Solver2CaptchaService.

Parameters:

Name Type Description Default
credentials dict

The credentials for the 2Captcha API.

required

report_bad_captcha() -> None

Reports a captcha as unsolvable to the 2Captcha API.

This method should be called when a captcha provided by 2Captcha was rejected by the target website.

report_good_captcha() -> None

Reports a captcha as solved successfully to the 2Captcha API.

This method should be called when a captcha provided by 2Captcha was accepted by the target website.

solve(version: str, page_url: str, google_key: str, action: str = 'verify') -> str

Solves a captcha using the specified version.

Parameters:

Name Type Description Default
version str

The version of the captcha (e.g., 'v2' or 'v3').

required
page_url str

The URL of the page with the captcha.

required
google_key str

The Google reCAPTCHA key.

required
action str

The action to perform. Defaults to 'verify'.

'verify'

Raises:

Type Description
Exception

If the captcha version is not implemented or if solving fails.

Returns:

Name Type Description
str str

The solution to the captcha.