woob.capabilities.captcha

class CapCaptchaSolver[source]

Bases: Capability

Provide CAPTCHA solving

RETRIES = 30
WAIT_TIME = 2
create_job(job)[source]

Start a CAPTCHA solving job

The job.id shall be filled. The CAPTCHA is not solved yet when the method returns.

Parameters

job (SolverJob) – job to start

Raises

NotImplementedError if CAPTCHA type is not supported

Raises

CaptchaError in case of other error

poll_job(job)[source]

Check if a job was solved

If job is solved, return True and fill job.solution. Return False if solution is still pending. In case of solving problem, an exception may be raised.

It should not wait for the solution but return the current state.

Parameters

job (SolverJob) – job to check and to fill when solved

Returns

True if the job was solved

Return type

bool

Raises

CaptchaError

solve_captcha_blocking(job)[source]

Start a CAPTCHA solving job and wait for its solution

Parameters

job (SolverJob) – job to start and solve

Raises

CaptchaError

solve_catpcha_blocking(job)[source]

Typoed method that will disappear in an upcoming version

report_wrong_solution(job)[source]

Report a solved job as a wrong solution

Sometimes, jobs are solved, but the solution is rejected by the CAPTCHA site because the solution is wrong. This method reports the solution as wrong to the CAPTCHA solver.

Parameters

job (SolverJob) – job to flag

get_balance()[source]

Get the prepaid balance left

Return type

float

class SolverJob(id='', url=NotLoaded, backend=None)[source]

Bases: BaseObject

Variables
  • url – (str) url

  • solution – (str) CAPTCHA solution

class RecaptchaJob(id='', url=NotLoaded, backend=None)[source]

Bases: SolverJob

Variables
  • url – (str) url

  • solution – (str) CAPTCHA solution

  • site_url – (str) Site URL for ReCaptcha service

  • site_key – (str) Site key for ReCaptcha service

  • solution_challenge – (str) Challenge ID of the solution (output value)

class RecaptchaV2Job(id='', url=NotLoaded, backend=None)[source]

Bases: SolverJob

Variables
  • url – (str) url

  • solution – (str) CAPTCHA solution

  • site_url – (str) Site URL for NoCaptcha service

  • site_key – (str) Site key for NoCaptcha service

class RecaptchaV3Job(id='', url=NotLoaded, backend=None)[source]

Bases: SolverJob

Variables
  • url – (str) url

  • solution – (str) CAPTCHA solution

  • site_url – (str) Site URL for ReCaptcha service

  • site_key – (str) Site key for ReCaptcha service

  • action – (str) Website owner defines what user is doing on the page through this parameter.

  • min_score – (float) Minimum score the reCaptcha response is required to have to be valid.

  • is_enterprise – (bool) If it is a reCaptcha enterprise

class ImageCaptchaJob(id='', url=NotLoaded, backend=None)[source]

Bases: SolverJob

Variables
  • url – (str) url

  • solution – (str) CAPTCHA solution

  • image – (bytes) data of the image to solve

class HcaptchaJob(id='', url=NotLoaded, backend=None)[source]

Bases: SolverJob

Variables
  • url – (str) url

  • solution – (str) CAPTCHA solution

  • site_url – (str) Site URL for HCaptcha service

  • site_key – (str) Site key for HCaptcha service

class GeetestV4Job(id='', url=NotLoaded, backend=None)[source]

Bases: SolverJob

Variables
  • url – (str) url

  • solution – (str) CAPTCHA solution

  • site_url – (str) Site URL for Geetest service

  • gt – (str) Site domain public key

exception CaptchaError[source]

Bases: UserError

Generic solving error

exception UnsolvableCaptcha[source]

Bases: CaptchaError

CAPTCHA is too hard or impossible

exception InvalidCaptcha[source]

Bases: CaptchaError

CAPTCHA cannot be used (e.g. invalid image format)

exception InsufficientFunds[source]

Bases: CaptchaError

Not enough funds to pay solution

exception_to_job(exc)[source]