def captcha_read(): captchaBox = [] captchaBox = firefox.find_elements_by_class_name('gc__2Qtwp') # if captchaBox != []: # if len(captchaBox[0].text) > 2: # break imageSearchName = captchaBox[0].text.split('\n')[-1] print("procurando por " + imageSearchName) captcha = [] captcha = firefox.find_elements_by_class_name('gc__3_EfD')[0] captchaSrc = captcha.get_attribute("src") data = captchaSrc.split(';base64,')[1] binary_data = a2b_base64(data) filename = imageSearchName + '.png' fd = open('BBB20/captchas/' + filename, 'wb') fd.write(binary_data) fd.close() processing.processImage(filename) points = processing.findInCaptcha(filename) if points != []: print("a imagem se encontra nos pontos: " + str(points[0]) + " X " + str(points[1])) print("o tamanho do captcha é " + str(captcha.size['width']) + " X " + str(captcha.size['height'])) firefox.execute_script( "window.scrollTo(0, document.body.scrollHeight);") posX = points[0] - captcha.size['width'] / 2 posY = points[1] - captcha.size['height'] / 2 ac.move_to_element(captcha).move_by_offset(posX, posY).click().perform() time.sleep(5) else: print("erro - captcha não encontrado")
except: pass captchaSrc = captcha.get_attribute("src") data = captchaSrc.split(';base64,')[1] binary_data = a2b_base64(data) filename = imageSearchName + '.png' fd = open('captchas20/' + filename, 'wb') fd.write(binary_data) fd.close() processing.processImage(filename) points = processing.findInCaptcha(filename) if points != []: print("a imagem se encontra nos pontos: " + str(points[0]) + " X " + str(points[1])) print("o tamanho do captcha é " + str(captcha.size['width']) + " X " + str(captcha.size['height'])) posX = points[0] - captcha.size['width'] / 2 posY = points[1] - captcha.size['height'] / 2 ac.move_to_element(captcha).move_by_offset(posX, posY).click().perform() time.sleep(10) else: print("erro - captcha não encontrado")