Package: captchaai
Python Module for captchaAI APIThe easiest way to quickly integratecaptchaAIcaptcha solving service into your code to automate solving of any types of captcha.Python Module for captchaAI APIInstallationConfigurationcaptchaAI instance optionsSolve captchaCaptcha optionsNormal CaptchaReCaptcha v2ReCaptcha v3hCaptchaOther methodssend / getResultbalancereportError handlingProxiesAsync callsInstallationThis package can be installed with Pip:pip3 install captchaAIConfigurationcaptchaAI instance can be created like this:fromcaptchaAIimportcaptchaAIsolver=captchaAI('YOUR_API_KEY')Also there are few options that can be configured:config={'apiKey':'YOUR_API_KEY','defaultTimeout':120,'recaptchaTimeout':240,'pollingInterval':10,}solver=captchaAI(**config)captchaAI instance optionsOptionDefault valueDescriptiondefaultTimeout120Polling timeout in seconds for all captcha types except ReCaptcha. Defines how long the module tries to get the answer fromres.phpAPI endpointrecaptchaTimeout240Polling timeout for ReCaptcha in seconds. Defines how long the module tries to get the answer fromres.phpAPI endpointpollingInterval10Interval in seconds between requests tores.phpAPI endpoint, setting values less than 5 seconds is not recommendedSolve captchaWhen you submit any image-based captcha use can provide additional options to help captchaAI workers to solve it properly.Captcha optionsOptionDefault ValueDescriptionnumeric0Defines if captcha contains numeric or other symbols [see more info in the API docs][post options]minLength0minimal answer lenghtmaxLength0maximum answer lengthphrase0defines if the answer contains multiple words or notcaseSensitive0defines if the answer is case sensitivecalc0defines captcha requires calculationlang-defines the captcha language, see the [list of supported languages]hintImg-an image with hint shown to workers with the captchahintText-hint or task text shown to workers with the captchaBelow you can find basic examples for every captcha type. Check outexamples directoryto find more examples with all available options.Normal CaptchaTo bypass a normal captcha (distorted text on image) use the following method. This method also can be used to recognize any text on the image.result=solver.normal('path/to/captcha.jpg',param1=...,...)# ORresult=solver.normal('https://site-with-captcha.com/path/to/captcha.jpg',param1=...,...)ReCaptcha v2Use this method to solve ReCaptcha V2 and obtain a token to bypass the protection.result=solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',url='https://mysite.com/page/with/recaptcha',param1=...,...)ReCaptcha v3This method provides ReCaptcha V3 solver and returns a token.result=solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',url='https://mysite.com/page/with/recaptcha',version='v3',param1=...,...)hCaptchaUse this method to solve hCaptcha challenge. Returns a token to bypass captcha.result=solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001',url='https://www.site.com/page/',param1=...,...)Other methodssend / getResultThese methods can be used for manual captcha submission and answer polling.importtime.....id=solver.send(file='path/to/captcha.jpg')time.sleep(20)code=solver.get_result(id)balanceUse this method to get your account's balancebalance=solver.balance()reportUse this method to report good or bad captcha answer.solver.report(id,True)# captcha solved correctlysolver.report(id,False)# captcha solved incorrectlyError handlingIn case of an error, the captcha solver throws an exception. It's important to properly handle these cases. We recommend usingtry exceptto handle exceptions.try:result=solver.recaptcha(sitekey=site_key,url=url)exceptValidationExceptionase:# invalid parameters passedprint(e)exceptNetworkExceptionase:# network error occurredprint(e)exceptApiExceptionase:# api respond with errorprint(e)exceptTimeoutExceptionase:# captcha is not solved so farprint(e)ProxiesYou can pass your proxy as an additional argument for methods: recaptcha, funcaptcha and geetest. The proxy will be forwarded to the API to solve the captcha.proxy={'type':'HTTPS','uri':'login:password@IP_address:PORT'}Async callsYou can also make async calls withasyncio, for example:importasyncioimportconcurrent.futuresfromcaptchaAIimportcaptchaAIcaptcha_result=awaitcaptchaSolver(image)asyncdefcaptchaSolver(image):loop=asyncio.get_running_loop()withconcurrent.future.ThreadPoolExecutor()aspool:result=awaitloop.run_in_executor(pool,lambda:captchaAI(API_KEY).normal(image))returnresult