Skip to main content

Universal interface to captcha solving services

Project description

Captcha Solution Python Package

Captcha Solution package is a simple interface to multiple captcha solving services.

Simple Image Captcha

The simplest case is to solve captcha image stored into file. Pass the file handler to the solve method. The solution will be stored into "solution" key of returned result. In "raw" key there is a full original response that captcha service returned.

from captcha_solution import CaptchaSolver

solver = CaptchaSolver('anticaptcha', api_key='YOUR-API-KEY')
with open('captcha.png', 'rb') as inp:
    res = solver.solve(inp)
    print(res['solution'])

Custom Captcha

If you want to solve non-image type of captcha (text captcha, recaptcha, etc) you have to use same solve method but you need to pass the dict of parameters. Each captcha service has its own request data schema so you need to consult with documentation to figure out format of request

Example, solving recaptcha with 2captcha.com

Documentation is https://2captcha.com/2captcha-api?form=3019071#solving_recaptchav2_new

Required POST parameters are: key, method, googlekey, pageurl. You do not have to pass key (api key), it is already done by solver. The code would be like:

res = solver.solve({
  "method": "userrecaptcha",
  "googlekey": "VALUE-OF-SITE-KEY",
  "pageurl": "URL-OF-PAGE-WHERE-RECAPTCHA-IS-DISPLAYED"
})
print('Solution: %s' % res['solution'])
print('Raw Response: %s' % res['raw'])

Example, solving recaptcha with anti-captcha.com

Documentation is https://anticaptcha.atlassian.net/wiki/spaces/API/pages/5079084/Captcha+Task+Types We need to use NoCaptchaTaskProxyless type of task. This task requires to provide at least these keys: type, websiteURL, websiteKey Code will looks like:

res = solver.solve({
  "type": "NoCaptchaTaskProxyless",
  "websiteKEY": "VALUE-OF-SITE-KEY",
  "websiteURL": "URL-OF-PAGE-WHERE-RECAPTCHA-IS-DISPLAYED"
})
print('Solution: %s' % res['solution'])
print('Raw Response: %s' % res['raw'])

Supported Captcha Services

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

captcha-solution-0.0.4.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file captcha-solution-0.0.4.tar.gz.

File metadata

  • Download URL: captcha-solution-0.0.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for captcha-solution-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c63a0158fe5f96b3128f314327c6faf6c43c36849c20711bec7fcded4085cdd3
MD5 d3c87e9212ea604acc55e5e680863396
BLAKE2b-256 a5148c8e157c9962b97b70c4c6025237c220f7a9ba48ca76df59102dbe72f51b

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