Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions captchasolver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Captcha Solver
A simple python script for solving simple captchas

## Modules Used

- pytesseract
- sys
- os
- PIL

## Requirements

- tesseract
`You can download tesseract from https://tesseract-ocr.github.io/tessdoc/Home.html`
- pytesseract
`pip install pytesseract`

- After you install tesseract replace with your tesseract location in csolver.py

## How to use
`python csolver.py captcha_image`

33 changes: 33 additions & 0 deletions captchasolver/csolver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytesseract
import sys
import os
from PIL import Image

# Set Tesseract location
pytesseract.pytesseract.tesseract_cmd = ""

# Image
im = sys.argv[1]


def resize_image(img):
img = Image.open(img)
img = img.resize((1000, 500), Image.NEAREST)
img.save("resized.png")


def solve(img):
resize_image(img)
cr = pytesseract.image_to_string("resized.png")
os.remove("resized.png")
# First resize captcha and try to read it.
if cr != "\x0c":
print(cr)
else:
# If it cant read try to read in normal size
cr = pytesseract.image_to_string(im)
print(cr)


# Run
solve(im)
1 change: 1 addition & 0 deletions captchasolver/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytesseract
Binary file added captchasolver/samples/c1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added captchasolver/samples/c2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added captchasolver/samples/c3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added captchasolver/samples/c4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added captchasolver/samples/c5.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added captchasolver/samples/c6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.