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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# init captcha solverwithCaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
balance=solver.get_balance()
Get service status (is the service is up?)
fromunicapsimportCaptchaSolver, CaptchaSolvingService# init captcha solverwithCaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# get status of the service (True - everything is Okay, False - probably the service is down)status=solver.get_status()
Get technical details after solving
fromunicapsimportCaptchaSolver, CaptchaSolvingService# init captcha solver and solve the captchawithCaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
solved=solver.solve_...(...)
# get cost of the solvingcost=solved.cost# get cookies (if any)cookies=solved.cookies# report good captchasolved.report_good()
# report bad captchasolved.report_bad()
# get solving start timestart_time=solved.start_time# get solving end timeend_time=solved.end_time
CAPTCHAs
Solve Image CAPTCHA
importpathlibfromunicapsimportCaptchaSolver, CaptchaSolvingServicefromunicaps.commonimportCaptchaCharType, CaptchaAlphabet# image file: it can be a Path, file-object or bytes.image_file=pathlib.Path(r'/tmp/captcha.png')
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_image_captcha(
image=image_file,
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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get page URL and site_key from your pagepage_url= ...
site_key= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get page url and site_key from your pagepage_url= ...
site_key= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get page URL, site_key and data_s from your pagepage_url= ...
site_key= ...
data_s= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
action= ...
min_score=0.7# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
action= ...
min_score=0.7# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepage_url= ...
site_key= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepublic_key= ...
page_url= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepage_url= ...
user_id= ...
session_id= ...
ws_sign= ...
ws_sign2= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepage_url= ...
gt_key= ...
challenge= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitepage_url= ...
captcha_id= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService# get CAPTCHA params from the target page/sitesite_key= ...
page_url= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingServicefromunicaps.commonimportCaptchaAlphabet, WorkerLanguage# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingService, exceptions# init captcha solverwithCaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAtry:
solved=solver.solve_recaptcha_v2(
site_key=site_key,
page_url=page_url
)
exceptexceptions.AccessDeniedError: # wrong API key or the current IP is bannedpassexceptexceptions.LowBalanceError: # low balancepassexceptexceptions.ServiceTooBusy: # no available slots to solve CAPTCHApassexceptexceptions.SolutionWaitTimeout: # haven't received a solution within N minutespassexceptexceptions.TooManyRequestsError: # request limit exceededpassexceptexceptions.BadInputDataError: # bad CAPTCHA data (bad image, wrong URL, etc.)passexceptexceptions.UnableToSolveError: # CAPTCHA unsolvablepassexceptexceptions.ProxyError: # bad proxypassexceptexceptions.NetworkError: # network connection errorpasselse:
# get response tokentoken=solved.solution.token
Misc
Create a task and wait for the result
fromunicapsimportCaptchaSolver, CaptchaSolvingServicefromunicaps.captchaimportRecaptchaV2# get page URL and site_key from your pagepage_url= ...
site_key= ...
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.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
fromunicapsimportCaptchaSolver, CaptchaSolvingServicefromunicaps.proxyimportProxyServer# get page URL and site_key from your pagepage_url= ...
site_key= ...
proxy='http://user:[email protected]:8080'user_agent='<USER AGENT STRING>'cookies= {'name': 'value', ...}
# init captcha solverwithCaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, "<PLACE YOUR API KEY HERE>") assolver:
# solve CAPTCHAsolved=solver.solve_recaptcha_v2(
site_key=site_key,
page_url=page_url,
proxy=ProxyServer(proxy),
user_agent=user_agent,
cookies=cookies
)
# get response tokentoken=solved.solution.token