[Python] Captcha Text Solving in Python

Discussão em 'Python' iniciado por Stack, Abril 27, 2025.

  1. Stack

    Stack Membro Participativo

    I have issue with solving text CAPTCHA on these images below. I tried using different method in python or API services but nothing is working for me. I also tried train my own model (streamlit) with 1000 images. Do you have any idea how to solve the captcha on these images?

    Captcha on all images in 6 characters long with capital letters A-Z.

    import requests
    from PIL import Image
    import pytesseract
    from io import BytesIO
    import os

    pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

    captcha_url = "URL"

    response = requests.get(captcha_url)
    img = Image.open(BytesIO(response.content))

    config = r'--oem 3 --psm 8 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    captcha_text = pytesseract.image_to_string(img, config=config).strip().replace(" ","").upper()
    captcha_text = ''.join([c for c in captcha_text if c.isalpha()])[:6]

    print("CAPTCHA OCR RESULT:", captcha_text)


    Examples:

    [​IMG]

    Continue reading...

Compartilhe esta Página