You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Text Captcha is a type of captcha that is represented as text and doesn't contain images.
Usually you have to answer a question to pass the verification.
For example: "If tomorrow is Saturday, what day is today?".
1 Support of solving reCAPTCHA on Google services (e.g. Google Search) 2 Support of solving via proxy server 3 Support of passing custom cookies 4 Support of passing custom User-Agent header
fromanycaptchaimportSolver, Serviceasyncdefmain():
asyncwithSolver(Service.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
balance=awaitsolver.get_balance()
...
Get service status (is the service is up?)
fromanycaptchaimportSolver, Serviceasyncdefmain():
withSolver(Service.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# get status of the service (True - everything is Okay, False - probably the service is down)status=awaitsolver.get_status()
...
Get technical details after solving
fromanycaptchaimportSolver, Serviceasyncdefmain():
# init captcha solver and solve the captchawithSolver(Service.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
solved=awaitsolver.solve_...(...)
# get cost of the solvingcost=solved.cost# get cookies (if any)cookies=solved.cookies# report good captchaawaitsolved.report_good()
# report bad captchaawaitsolved.report_bad()
# get solving start timestart_time=solved.start_time# get solving end timeend_time=solved.end_time
CAPTCHAs
Solve Image CAPTCHA
frompathlibimportPathfromanycaptchaimportSolver, ServicefromanycaptchaimportCaptchaAlphabetfromanycaptchaimportCaptchaCharTypeasyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_image_captcha(
image=Path('captcha.jpg'), # it can be a Path, file-object or bytes.char_type=CaptchaCharType.ALPHA, # optionalis_phrase=False, # optionalis_case_sensitive=True, # optionalis_math=False, # optionalmin_len=4, # optionalmax_len=6, # optionalalphabet=CaptchaAlphabet.LATIN, # optionalcomment='Type RED letters only'# optional
)
# get CAPTCHA texttoken=solved.solution.text
Solve reCAPTCHA v2
fromanycaptchaimportSolver, Service# get page URL and site_key from your pagepage_url= ...
site_key= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_recaptcha_v2(
site_key=site_key,
page_url=page_url,
data_s='<data-s value>', # optionalapi_domain='<"google.com" or "recaptcha.net">'# optional
)
# get response tokentoken=solved.solution.token
Solve reCAPTCHA v2 Invisible
fromanycaptchaimportSolver, Service# get page url and site_key from your pagepage_url= ...
site_key= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_recaptcha_v2(
site_key=site_key,
page_url=page_url,
is_invisible=True,
data_s='<data-s value>', # optionalapi_domain='<"google.com" or "recaptcha.net">'# optional
)
# get response tokentoken=solved.solution.token
Solve reCAPTCHA v2 Enterprise
fromanycaptchaimportSolver, Service# get page URL, site_key and data_s from your pagepage_url= ...
site_key= ...
data_s= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_recaptcha_v2(
site_key=site_key,
page_url=page_url,
is_enterprise=True,
data_s=data_s, # optionalapi_domain='<"google.com" or "recaptcha.net">'# optional
)
# get response tokentoken=solved.solution.token
Solve reCAPTCHA v3
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
action= ...
min_score=0.7asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_recaptcha_v3(
site_key=site_key,
page_url=page_url,
action=action, # optionalmin_score=min_score, # optionalapi_domain='<"google.com" or "recaptcha.net">'# optional
)
# get response tokentoken=solved.solution.token
Solve reCAPTCHA v3 Enterprise
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
action= ...
min_score=0.7asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_recaptcha_v3(
site_key=site_key,
page_url=page_url,
is_enterprise=True,
action=action, # optionalmin_score=min_score, # optionalapi_domain='<"google.com" or "recaptcha.net">'# optional
)
# get response tokentoken=solved.solution.token
Solve hCaptcha
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_hcaptcha(
site_key=site_key,
page_url=page_url,
api_domain='< "hcaptcha.com" or "js.hcaptcha.com" >'# optional
)
# get response tokentoken=solved.solution.token
Solve hCaptcha Invisible
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_hcaptcha(
site_key=site_key,
page_url=page_url,
is_invisible=True,
api_domain='< "hcaptcha.com" or "js.hcaptcha.com" >'# optional
)
# get response tokentoken=solved.solution.token
Solve FunCaptcha
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepublic_key= ...
page_url= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_funcaptcha(
public_key=public_key,
page_url=page_url,
service_url='<value of surl parameter>', # optionalblob='<value of data[blob] parameter>'# optional
)
# get response tokentoken=solved.solution.token
Solve KeyCaptcha
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepage_url= ...
user_id= ...
session_id= ...
ws_sign= ...
ws_sign2= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_keycaptcha(
page_url=page_url,
user_id=user_id,
session_id=session_id,
ws_sign=ws_sign,
ws_sign2=ws_sign2
)
# get response tokentoken=solved.solution.token
Solve Geetest
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepage_url= ...
gt_key= ...
challenge= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_geetest(
page_url=page_url,
gt_key=gt_key,
challenge=challenge,
api_server='<value of api_server parameter>'# optional
)
# get response tokentoken=solved.solution.token
Solve Geetest v4
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitepage_url= ...
captcha_id= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_geetest_v4(
page_url=page_url,
captcha_id=captcha_id
)
# get solution datalot_number=solved.solution.lot_numberpass_token=solved.solution.pass_tokengen_time=solved.solution.gen_timecaptcha_output=solved.solution.captcha_output
Solve Capy Puzzle
fromanycaptchaimportSolver, Service# get CAPTCHA params from the target page/sitesite_key= ...
page_url= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_capy_puzzle(
site_key=site_key,
page_url=page_url,
api_server='<for example "https://api.capy.me">', # optionalchallenge_type='<"puzzle" or "avatar">'# optional
)
# get solution datacaptchakey=solved.solution.captchakeychallengekey=solved.solution.challengekeyanswer=solved.solution.answer
Solve a text CAPTCHA
fromanycaptchaimportSolver, ServicefromanycaptchaimportCaptchaAlphabetfromanycaptchaimportWorkerLanguageasyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_text_captcha(
text='Si mañana es domingo, ¿qué día es hoy?',
alphabet=CaptchaAlphabet.LATIN, # optionallanguage=WorkerLanguage.SPANISH# optional
)
# get answeranswer=solved.solution.text# Sábado
Error handling
Catch exceptions
importanycaptchafromanycaptchaimportSolver, Serviceasyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAtry:
solved=solver.solve_recaptcha_v2(
site_key=site_key,
page_url=page_url,
)
exceptanycaptcha.AccessDeniedError: # wrong API key or the current IP is bannedpassexceptanycaptcha.LowBalanceError: # low balancepassexceptanycaptcha.ServiceTooBusy: # no available slots to solve CAPTCHApassexceptanycaptcha.SolutionWaitTimeout: # haven't received a solution within N minutespassexceptanycaptcha.TooManyRequestsError: # request limit exceededpassexceptanycaptcha.BadInputDataError: # bad CAPTCHA data (bad image, wrong URL, etc.)passexceptanycaptcha.UnableToSolveError: # CAPTCHA unsolvablepassexceptanycaptcha.ProxyError: # bad proxypasselse:
# get response tokentoken=solved.solution.token
Misc
Create a task and wait for the result
fromanycaptchaimportSolver, Servicefromanycaptcha.captchaimportRecaptchaV2# get page URL and site_key from your pagepage_url= ...
site_key= ...
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# create a tasktask=solver.create_task(
RecaptchaV2(site_key, page_url)
)
# print task IDprint(task.task_id)
# wait for task to be completedsolved=task.wait()
# get response tokentoken=solved.solution.token
Add proxy, cookies and User-Agent
fromanycaptchaimportSolver, Service# get page URL and site_key from your pagepage_url= ...
site_key= ...
proxy='http://user:password@domain.com:8080'# any formatuser_agent='<USER AGENT STRING>'cookies= {'name': 'value', ...}
asyncdefmain():
withSolver(Service.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_recaptcha_v2(
site_key=site_key,
page_url=page_url,
proxy=proxy,
user_agent=user_agent,
cookies=cookies
)
# get response tokentoken=solved.solution.token