Skip to main content

Universal CAPTCHA Solver for humans

Project description

Unicaps

PyPI pyversions PyPI version fury.io PyPI status

Unicaps is a unified Python API for CAPTCHA solving services.

PLEASE NOTE
⚠ A solving service API key is required to use this package!
⚠ The list of the supported services you can find in the table below.

Key Features

  • A unified Python interface that is independent of the service used
  • Uses native service protocol/endpoints (eg, no needs in patching hosts file)
  • Supports 10 types of CAPTCHAs
  • Supports 5 CAPTCHA solving services (3 more would be added soon)
  • Written Pythonic way and is intended for humans

Installation

pip install unicaps

Simple Usage Example

>>> from unicaps import CaptchaSolver, CaptchaSolvingService
>>> solver = CaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, api_key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
>>> solver.get_balance()
2.84161
>>> solved = solver.solve_image_captcha(open("captcha.jpg", "rb"), is_phrase=False, is_case_sensitive=True)
>>> solved.solution.text
'w93Bx'
>>> solved.cost
0.00078
>>> solved.report_good()
True

Supported CAPTCHAs / Services

CAPTCHA➡ \ Service⬇ Image Text reCAPTCHA v2 reCAPTCHA v3 FunCaptcha KeyCAPTCHA Geetest hCaptcha Capy TikTok
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

Image CAPTCHA

Service Regular Case Sensitive Phrase Numbers only Letters only Math Length Language Comment for worker
2captcha.com Cyrillic/Latin
anti-captcha.com Latin
azcaptcha.com Latin
cptch.net Cyrillic/Latin
rucaptcha.com Cyrillic/Latin

Text CAPTCHA

What is this?

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?".

Service Language
2captcha.com English, Russian
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com English, Russian

reCAPTCHA v2

Service Regular Invisible Enterprise Google service1 Proxy2 Cookies3 User-Agent4
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

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

reCAPTCHA v3

Service Regular Enterprise Proxy Cookies User-Agent
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

FunCaptcha (Arkose Labs)

Service Regular Data (BLOB) Proxy Cookies User-Agent
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

KeyCAPTCHA

Service Regular Proxy Cookies User-Agent
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

Geetest

Service Regular API server GetLib Proxy Cookies User-Agent
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

hCaptcha

Service Regular Invisible Custom Data Proxy Cookies User-Agent
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

Capy

Service Regular API server Proxy Cookies User-Agent
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

TikTok CAPTCHA

Service Regular Proxy Cookies User-Agent
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

Supported Proxy types

Service HTTP HTTPS SOCKS 4 SOCKS 5
2captcha.com
anti-captcha.com
azcaptcha.com
cptch.net
rucaptcha.com

How to...

Common

Get balance
from unicaps import CaptchaSolver, CaptchaSolvingService

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
balance = solver.get_balance()
Get service status (is the service is up?)
from unicaps import CaptchaSolver, CaptchaSolvingService

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
# get status of the service (True - everything is Okay, False - the service is down)
status = solver.get_status()
Get technical details after solving
from unicaps import CaptchaSolver, CaptchaSolvingService

# init captcha solver and solve the captcha
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
solved = solver.solve_...(...)

# get cost of the solving
cost = solved.cost

# get cookies (if any)
cookies = solved.cookies

# report good captcha
solved.report_good()

# report bad captcha
solved.report_bad()

# get solving start time
start_time = solved.start_time

# get solving end time
end_time = solved.end_time

Solving

Image CAPTCHA
import pathlib

from unicaps import CaptchaSolver, CaptchaSolvingService
from unicaps.common import CaptchaCharType, CaptchaAlphabet

# get image file
image_file = pathlib.Path(r'/tmp/captcha.png')

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
solved = solver.solve_image_captcha(
    image=image_file,
    char_type=CaptchaCharType.ALPHA,
    is_phrase=False,
    is_case_sensitive=True,
    is_math=False,
    min_len=4,
    max_len=6,
    alphabet=CaptchaAlphabet.LATIN,
    comment='Type RED letters only'
)
# get response token
token = solved.solution.text
reCAPTCHA v2
from unicaps import CaptchaSolver, CaptchaSolvingService

# get page URL and site_key from your page
page_url = ...
site_key = ...

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
solved = solver.solve_recaptcha_v2(
    site_key=site_key,
    page_url=page_url
)
# get response token
token = solved.solution.token
reCAPTCHA v2 Invisible
from unicaps import CaptchaSolver, CaptchaSolvingService

# get page url and site_key from your page
page_url = ...
site_key = ...

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
solved = solver.solve_recaptcha_v2(
    site_key=site_key,
    page_url=page_url,
    is_invisible=True
)
# get response token
token = solved.solution.token
reCAPTCHA v2 Enterprise
from unicaps import CaptchaSolver, CaptchaSolvingService

# get page URL, site_key and data_s from your page
page_url = ...
site_key = ...
data_s = ...

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.TWOCAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
solved = solver.solve_recaptcha_v2(
    site_key=site_key,
    page_url=page_url,
    data_s=data_s,
    is_enterprise=True
)
# get response token
token = solved.solution.token
reCAPTCHA v3
from unicaps import CaptchaSolver, CaptchaSolvingService

# get page URL, site_key and action from your page
page_url = ...
site_key = ...
action = ...
min_score = 0.7

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
solved = solver.solve_recaptcha_v3(
    site_key=site_key,
    page_url=page_url,
    action=action,
    min_score=min_score
)
# get response token
token = solved.solution.token
hCaptcha
from unicaps import CaptchaSolver, CaptchaSolvingService

# get page URL and site_key from your page
page_url = ...
site_key = ...

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
solved = solver.solve_hcaptcha(
    site_key=site_key,
    page_url=page_url
)
# get response token
token = solved.solution.token

Error handling

Exceptions
from unicaps import CaptchaSolver, CaptchaSolvingService, exceptions

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
try:
    solved = solver.solve_recaptcha_v2(
        site_key=site_key,
        page_url=page_url
    )
except exceptions.AccessDeniedError:  # wrong API key or the current IP is banned
    pass
except exceptions.LowBalanceError:  # low balance
    pass
except exceptions.ServiceTooBusy:  # no available slots to solve CAPTCHA
    pass
except exceptions.SolutionWaitTimeout:  # haven't received a solution within N minutes
    pass
except exceptions.TooManyRequestsError:  # request limit exceeded
    pass
except exceptions.BadInputDataError:  # bad CAPTCHA data (bad image, wrong URL, etc.)
    pass
except exceptions.UnableToSolveError:  # CAPTCHA unsolvable
    pass
except exceptions.ProxyError:  # bad proxy
    pass
except exceptions.NetworkError:  # network connection error
    pass
else:
    # get response token
    token = solved.solution.token

Proxy

Add proxy, cookies and User-Agent
from unicaps import CaptchaSolver, CaptchaSolvingService
from unicaps.proxy import ProxyServer

# get page URL and site_key from your page
PAGE_URL = ...
SITE_KEY = ...
PROXY = 'http://user:password@domain.com:8080'
USER_AGENT = '<USER AGENT STRING>'
COOKIES = {'name': 'value', ...}

# init captcha solver
solver = CaptchaSolver(CaptchaSolvingService.ANTI_CAPTCHA, "PLACE YOUR API KEY HERE")
# solve CAPTCHA
solved = solver.solve_recaptcha_v2(
    site_key=site_key,
    page_url=page_url,
    proxy=ProxyServer(PROXY),
    user_agent=USER_AGENT,
    cookies=COOKIES
)
# get response token
token = solved.solution.token

Code examples

Examples

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unicaps-1.0.0rc2.tar.gz (32.1 kB view details)

Uploaded Source

Built Distribution

unicaps-1.0.0rc2-py3-none-any.whl (44.0 kB view details)

Uploaded Python 3

File details

Details for the file unicaps-1.0.0rc2.tar.gz.

File metadata

  • Download URL: unicaps-1.0.0rc2.tar.gz
  • Upload date:
  • Size: 32.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for unicaps-1.0.0rc2.tar.gz
Algorithm Hash digest
SHA256 fe3b1711622406883aabe6d6641ae619f60d28826b8921e4062529a4f46e8b52
MD5 5457a66b9ae8b92c21b3c453fceafb30
BLAKE2b-256 03ea94bfc1ca2f117c4f70458fa6df2c4db14017f69fdb5530b1eae9f72939d9

See more details on using hashes here.

File details

Details for the file unicaps-1.0.0rc2-py3-none-any.whl.

File metadata

  • Download URL: unicaps-1.0.0rc2-py3-none-any.whl
  • Upload date:
  • Size: 44.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for unicaps-1.0.0rc2-py3-none-any.whl
Algorithm Hash digest
SHA256 fc43c7839e406c0b13bd5f17ae1c768d90233113e1c52396587b40c73a777ddb
MD5 fb4f33a1432db37e7362397892eab08f
BLAKE2b-256 2c9121db86812f29c340dcaa44de728cdccd8e515b84051a1bf77d386e78a2d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page