Skip to content

Instantly share code, notes, and snippets.

@scrapehero
Last active January 7, 2023 11:02
Show Gist options
  • Star 20 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save scrapehero/b85a280dc0d993f665c91e0332cf618f to your computer and use it in GitHub Desktop.
Save scrapehero/b85a280dc0d993f665c91e0332cf618f to your computer and use it in GitHub Desktop.
import pytesseract
import sys
import argparse
try:
import Image
except ImportError:
from PIL import Image
from subprocess import check_output
def resolve(path):
print("Resampling the Image")
check_output(['convert', path, '-resample', '600', path])
return pytesseract.image_to_string(Image.open(path))
if __name__=="__main__":
argparser = argparse.ArgumentParser()
argparser.add_argument('path',help = 'Captcha file path')
args = argparser.parse_args()
path = args.path
print('Resolving Captcha')
captcha_text = resolve(path)
print('Extracted Text',captcha_text)
@Shonty10
Copy link

Code works fine but doesn't extract the captcha.
Capture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment