Skip to main content

Pure Python, lightweight, Pillow-based solver for the Amazon's text captcha.

Project description

The motivation behind the creation of this library is taking its start from the genuinely simple idea: "I don't want to use pytesseract or some other non-amazon-specific OCR services, nor do I want to install some executables to just solve a captcha. I desire to get a solution within 1-2 lines of code without any heavy add-ons, using a pure Python."


Pure Python, lightweight, Pillow-based solver for Amazon's text captcha.

Accuracy Timing Size Version Python version Downloads

Installation

pip install amazoncaptcha

Quick Snippet

from amazoncaptcha import AmazonCaptcha

captcha = AmazonCaptcha('captcha.jpg')
solution = captcha.solve()

# Or: solution = AmazonCaptcha('captcha.jpg').solve()

Status

Status Build Status codecov Requirements Status CodeFactor Grade Implementation

Usage

Browsing Amazon using selenium and stuck on captcha? The class method below will do all the "dirty" work of extracting an image from the webpage for you. Practically, it takes a screenshot from your webdriver, crops the captcha, and stores it into bytes array, which is then used to create an AmazonCaptcha instance. This also means avoiding any local savings.

from amazoncaptcha import AmazonCaptcha
from selenium import webdriver

driver = webdriver.Chrome() # This is a simplified example
driver.get('https://www.amazon.com/errors/validateCaptcha')

captcha = AmazonCaptcha.fromdriver(driver)
solution = captcha.solve()

If you are not using selenium or the previous method is not just the case for you, it is possible to use a captcha link directly. This class method will request the url, check the content type and store the response content into bytes array to create an instance of AmazonCaptcha.

from amazoncaptcha import AmazonCaptcha

link = 'https://images-na.ssl-images-amazon.com/captcha/usvmgloq/Captcha_kwrrnqwkph.jpg'

captcha = AmazonCaptcha.fromlink(link)
solution = captcha.solve()

In addition, if you are a machine learning or neural network developer and are looking for some training data, firstly check the captchas folder. It currently contains 13000 solved captchas with unique patterns. For more solved images, consider using AmazonCaptchaCollector instance with a really simple API sampled below. An image will be stored, only if there is a 100% answer. However, if you've noticed a wrong solution, please, create an issue using the corresponding template.

from amazoncaptcha import AmazonCaptchaCollector

output_folder = '/path/to/output/folder' # where you want to store captchas
target = 100000 # final number of solved captchas you want to get
processes = 10 # number of simultaneous processes

if __name__ == '__main__':
    collector = AmazonCaptchaCollector(output_folder)
    collector.start(target, processes)

Help the Development

If you are willing to help the development, consider setting keep_logs argument of the solve method to True. Here is the example, if you are using fromdriver class method. If set to True, all the links of the unsolved captcha will be stored, so later you can open the issue and send the logs.

from amazoncaptcha import AmazonCaptcha
from selenium import webdriver

driver = webdriver.Chrome() # This is a simplified example
driver.get('https://www.amazon.com/errors/validateCaptcha')

captcha = AmazonCaptcha.fromdriver(driver)
solution = captcha.solve(keep_logs=True)

If you have any suggestions or ideas of additional instances and methods, which you would like to see in this library, please, feel free to contact the owner via email or fork'n'pull to repository. Any contribution is highly appreciated!

Additional

  • Just FYI, pip will install only the module itself. However, if you are using git clone, be aware that you will also clone 50 MB of captchas currently located in the repository.
  • If you want to see the History of Changes, Code of Conduct, Contributing Policy, or License, use these inline links to navigate based on your needs.
  • If you are facing any errors, please, report your situation via an issue.
  • This project is for educational and research purposes only. Any actions and/or activities related to the material contained on this GitHub Repository is solely your responsibility. The author will not be held responsible in the event any criminal charges be brought against any individuals misusing the information in this GitHub Repository to break the law.

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

amazoncaptcha-0.4.2.tar.gz (874.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amazoncaptcha-0.4.2-py3-none-any.whl (934.6 kB view details)

Uploaded Python 3

File details

Details for the file amazoncaptcha-0.4.2.tar.gz.

File metadata

  • Download URL: amazoncaptcha-0.4.2.tar.gz
  • Upload date:
  • Size: 874.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.7.4

File hashes

Hashes for amazoncaptcha-0.4.2.tar.gz
Algorithm Hash digest
SHA256 ed9d36eed0671c1449151d757acb51dd5c765b5abdf9ebfcfd192d1607eacd9e
MD5 b3ace8f50e04b38223bd74592db1f6cb
BLAKE2b-256 42dd8d825e125b8f0f0e365787403978d10bb3bd5314e02d6bb67c404a118e4e

See more details on using hashes here.

File details

Details for the file amazoncaptcha-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: amazoncaptcha-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 934.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.7.4

File hashes

Hashes for amazoncaptcha-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8bb7c8a7f97e7eaecfcefca2f57062bdda2b0c20cf24f913044e6901774f4629
MD5 65ce55a0919a3889793ad7980bb846ee
BLAKE2b-256 bb9c460be34048b769b9bf6186f07ae83e954e61eff25a502b93055b473454bd

See more details on using hashes here.

Supported by

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