
    i)                         S SK Jr  S SKr S SKJr  SSKJrJrJ	r	J
r
JrJr   S SKrSSKJr   " S	 S
\5      r\" 5         g! \ a	    S SKJr   N<f = f! \ a	    \" S5      ef = f)    )absolute_importN)urlparse   )CaptchaServiceUnavailableCaptchaAPIErrorCaptchaTimeoutCaptchaParameterCaptchaBadJobIDCaptchaReportErrorz3Please install the python module 'polling2' via pip   )Captchac                   P   ^  \ rS rSrU 4S jr\S 5       rS rS rS r	S r
SrU =r$ )	captchaSolver   c                    > [         [        U ]  S5        SU l        [        R
                  " 5       U l        SSSS.U l        g )N2captchazhttps://2captcha.comuserrecaptchahcaptcha	turnstile)	reCaptchahCaptchar   )superr   __init__hostrequestsSessionsessioncaptchaType)self	__class__s    J/app/mltbenv/lib/python3.13/site-packages/cloudscraper/captcha/2captcha.pyr   captchaSolver.__init__   s<    mT+J7*	'')("$
    c                    U R                   S;   a  [        SU R                    35      eSSSSSSS	S
SSS.
SSSSSSSSSSS.
S.nU R                  5       nUR                  S5      S:X  aY  UR                  S5      UR                  U5      ;   a4  [	        US    SUR                  U5      R                  US   5       35      eg g )N)i  i  z2Captcha: Server Side Error z]You've provided api_key parameter value is in incorrect format, it should contain 32 symbols.z,The api_key you've provided does not exists.z0You don't have sufficient funds on your account.z-pageurl parameter is missing in your request.a  No Slots Available.
You can receive this error in two cases:
1. If you solve ReCaptcha: the queue of your captchas that are not distributed to workers is too long. Queue limit changes dynamically and depends on total amount of captchas awaiting solution and usually it's between 50 and 100 captchas.
2. If you solve Normal Captcha: your maximum rate for normal captchas is lower than current rate on the server.You can change your maximum rate in your account's settings.zLThe request is sent from the IP that is not on the list of your allowed IPs.zlYour IP address is banned due to many frequent attempts to access the server using wrong authorization keys.zYou can get this error code when sending ReCaptcha V2. That happens if your request contains invalid pair of googlekey and pageurl. The common reason for that is that ReCaptcha is loaded inside an iframe hosted on another domain/subdomain.zYou can get this error code when sending ReCaptcha V2. That means that sitekey value provided in your request is incorrect: it's blank or malformed.zxYou made more than 60 requests within 3 seconds.Your account is banned for 10 seconds. Ban will be lifted automatically.)
ERROR_WRONG_USER_KEYERROR_KEY_DOES_NOT_EXISTERROR_ZERO_BALANCEERROR_PAGEURLERROR_NO_SLOT_AVAILABLEERROR_IP_NOT_ALLOWED	IP_BANNEDERROR_BAD_TOKEN_OR_PAGEURLERROR_GOOGLEKEYMAX_USER_TURNzWe are unable to solve your captcha - three of our workers were unable solve it or we didn't get an answer within 90 seconds (300 seconds for ReCaptcha V2). We will not charge you for that request.zZYou've provided api_key parameter value in incorrect format, it should contain 32 symbols.zLYou've provided captcha ID in wrong format. The ID can contain numbers only.z%You've provided incorrect captcha ID.zError is returned when 100% accuracy feature is enabled. The error means that max numbers of tries is reached but min number of matches not found.zgError is returned to your complain request if you already complained lots of correctly solved captchas.zYou can receive this error code when registering a pingback (callback) IP or domain.That happes if your request is coming from an IP address that doesn't match the IP address of your pingback IP or domain.ztYou can receive this error code when sending GeeTest. That error means that challenge value you provided is expired.zIAction parameter is missing or no value is provided for action parameter.)
ERROR_CAPTCHA_UNSOLVABLEr%   r&   ERROR_WRONG_ID_FORMATERROR_WRONG_CAPTCHA_IDERROR_BAD_DUPLICATESREPORT_NOT_RECORDEDERROR_IP_ADDRESERROR_TOKEN_EXPIREDERROR_EMPTY_ACTION)in.phpres.phpstatusr   request )status_coder   jsongetr   )responserequest_typeerrorsrPayloads       r!   checkErrorStatuscaptchaSolver.checkErrorStatus(   s   :-+.J8K_K_J`,abb )H,Z&X!PS
 )w LBt "\)0? )E,Z)w*Qp (QP (^&q#/*
X ==?<<!Q&8<<	+BfjjQ]F^+^!I&'qL)A)E)EhyFY)Z([\  ,_&r#   c                    ^ ^ T(       d  [        S5      eU 4S jn[        R                  " UU 4S jUSSS9nU(       a  g[        S5      e)	N.2Captcha: Error bad job id to request Captcha.c                    > TR                  U S5        U R                  (       a%  U R                  5       R                  S5      S:X  a  U $ g Nr8   r9   r   rC   okr=   r>   r?   r   s    r!   _checkRequest.captchaSolver.reportJob.<locals>._checkRequestg   :    !!(I6{{x}}228<Ar#   c                  r   > TR                   R                  TR                   S3TR                  ST SS.SS9$ )N/res.php	reportbad1keyactionidr=      paramstimeoutr   r>   r   api_keyjobIDr   s   r!   <lambda>)captchaSolver.reportJob.<locals>.<lambda>n   sA    DLL$$99+X&<<)	  % 	r#         check_successsteprZ   Tz52Captcha: Error - Failed to report bad Captcha solve.)r
   polling2pollr   r   r^   rL   r?   s   ``  r!   	reportJobcaptchaSolver.reportJoba   sS    !@ 	 ==	 (
  $G r#   c                    ^ ^ T(       d  [        S5      eU 4S jn[        R                  " UU 4S jUSSS9nU(       a  UR                  5       R	                  S5      $ [        S5      e)	NrF   c                    > TR                  U S5        U R                  (       a%  U R                  5       R                  S5      S:X  a  U $ g rH   rI   rK   s    r!   rL   /captchaSolver.requestJob.<locals>._checkRequest   rN   r#   c                  r   > TR                   R                  TR                   S3TR                  ST SS.SS9$ )NrP   r>   rR   rS   rW   rX   r[   r]   s   r!   r_   *captchaSolver.requestJob.<locals>.<lambda>   sA    DLL$$99+X&<<#	  % 	r#   ra   rb   rc   r:   z(2Captcha: Error failed to solve Captcha.)r
   rf   rg   r=   r>   r   rh   s   ``  r!   
requestJobcaptchaSolver.requestJob   sc    !"RSS	 ==	 (
  ==?&&y11 : r#   c                   ^ ^ U 4S jnT R                   USSS.mTR                  ST R                  U   US:X  a  SOSU05        T R                  (       a(  TR                  T R                  T R                  S	.5        [
        R                  " UU 4S
 jUSSS9nU(       a  UR                  5       R                  S5      $ [        S5      e)Nc                    > TR                  U S5        U R                  (       aI  U R                  5       R                  S5      S:X  a&  U R                  5       R                  S5      (       a  U $ g )Nr7   r9   r   r:   rI   rK   s    r!   rL   1captchaSolver.requestSolve.<locals>._checkRequest   sQ    !!(H5{{x}}228<AhmmoFYFYZcFdFdr#   r   iY  )rT   pageurlr=   soft_idmethodr   	googlekeysitekey)proxy	proxytypec                  V   > TR                   R                  TR                   S3T SSS9$ )Nz/in.phpFrW   )dataallow_redirectsrZ   )r   postr   )r}   r   s   r!   r_   ,captchaSolver.requestSolve.<locals>.<lambda>   s0    DLL%%99+W% %	 & r#   ra   rb   rc   r:   z'2Captcha: Error no job id was returned.)
r\   updater   rz   	proxyTyperf   rg   r=   r>   r
   )r   r   urlsiteKeyrL   r?   r}   s   `     @r!   requestSolvecaptchaSolver.requestSolve   s    	 <<	
 	d&&{3&+5K9g
 	
 ::KK!^^ 
 == (

 ==?&&y11!9 r#   c                    S nUR                  S5      (       d  [        S5      eUR                  S5      U l        UR                  S5      (       a  UR                  S5      (       d  [        UR                  S0 5      R                  S5      5      nUR                  (       d  [        S5      eUR
                  (       d  [        S5      eUR                  U l        UR
                  U l        OS U l         U R                  XU5      nU R                  U5      $ ! [        R                   aQ     U(       a  U R                  U5        O'! [        R                   a    [        SU S	35      ef = f[        S
U S35      ef = f)Nr\   z$2Captcha: Missing api_key parameter.rz   no_proxyhttpsz(Cannot parse proxy correctly, bad schemez(Cannot parse proxy correctly, bad netloczR2Captcha: Captcha solve took to long and also failed reporting the job the job id .z72Captcha: Captcha solve took to long to execute job id z, aborting.)r>   r	   r\   r   schemenetlocr   rz   r   rp   rf   TimeoutExceptionri   r   )r   r   r   r   captchaParamsr^   
hostParseds          r!   getCaptchaAnswercaptchaSolver.getCaptchaAnswer   sf     ++"6  %((3W%%m.?.?
.K.K!-"3"3GR"@"D"DW"MNJ$$&'QRR$$&'QRR'..DN#**DJDJ	%%k@E??5))(( 	NN5),, $hinhoopq 
 !I%P[\ 	s$   3"D E;+EE;$E((E;)r\   r   r   rz   r   r   )__name__
__module____qualname____firstlineno__r   staticmethodrC   ri   rp   r   r   __static_attributes____classcell__)r    s   @r!   r   r      s9    
 4 4p!JF*\& &r#   r   )
__future__r   r   r   ImportErrorurllib.parse
exceptionsr   r   r   r	   r
   r   rf    r   r    r#   r!   <module>r      st    & &! M cG cP y  &%&  M
K
LLMs   A  A  AAA!