Skip to content

Instantly share code, notes, and snippets.

@eliasalbuquerque
Last active January 15, 2024 12:03
Show Gist options
  • Save eliasalbuquerque/bc9dc4485582e252455c52c1a7274f86 to your computer and use it in GitHub Desktop.
Save eliasalbuquerque/bc9dc4485582e252455c52c1a7274f86 to your computer and use it in GitHub Desktop.
Curso Dev Aprender | Jhonatan de Souza

Desafio

Localizar e clicar no checkbox do captcha.

Código

# 202401 - Python 3.12.0
# 4.13 - Como quebrar captcha com reconhecimento de imagem


import pyautogui
import logging
import logging.config


# configurando logging:
logging.config.fileConfig(fname='config.ini', disable_existing_loggers=False)
logger = logging.getLogger(__name__)


def clicando_no_captcha():
    try:
        logging.info('INICIO: Clicando no captcha.')
        captcha = pyautogui.locateCenterOnScreen('assets/captcha.png')
        pyautogui.click(captcha, duration=1)
        logging.info('Captcha clicado.')

    except Exception as e:
        logging.error(f'Erro ao clicar no captcha: {e}', exc_info=True)
        pyautogui.alert('ERRO: Ocorreu um erro ao clicar no captcha')


if __name__ == '__main__':
    clicando_no_captcha()

Resultado Final

Log:

2024-01-02 19:16:43,067 - root - INFO - INICIO: Clicando no captcha.
2024-01-02 19:16:43,116 - PIL.PngImagePlugin - DEBUG - STREAM b'IHDR' 16 13
2024-01-02 19:16:43,116 - PIL.PngImagePlugin - DEBUG - STREAM b'sRGB' 41 1
2024-01-02 19:16:43,116 - PIL.PngImagePlugin - DEBUG - STREAM b'gAMA' 54 4
2024-01-02 19:16:43,116 - PIL.PngImagePlugin - DEBUG - STREAM b'pHYs' 70 9
2024-01-02 19:16:43,116 - PIL.PngImagePlugin - DEBUG - STREAM b'iTXt' 91 93
2024-01-02 19:16:43,116 - PIL.PngImagePlugin - DEBUG - STREAM b'IDAT' 196 235
2024-01-02 19:16:44,445 - root - INFO - Captcha clicado.

clicando-captcha


GitHub: eliasalbuquerque/python-automation

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