• 纯数字字符相加的验证码破解


    import time
    from pytesseract import pytesseract
    from selenium import webdriver
    from PIL import Image
    if __name__ == '__main__':
        browser = webdriver.Chrome(executable_path='D:pythonScriptschromedriver.exe')
        url = 'url'
        browser.get(url)
        browser.save_screenshot('D:图片print.png')
        element = browser.find_element_by_xpath('//*[@id="VerifCode"]')#验证码所在的xpath路径
        #获得验证码xy轴坐标
        location = element.location
        size = element.size
        rangle = (int(location['x']), int(location['y']), int(location['x'] + size['width']),
              int(location['y'] + size['height']))
        #浏览器最大化保存图片到指定文件夹下
        browser.maximize_window()
        im = Image.open('D:图片print.png')
        im = im.crop(rangle)
        im.save('验证码.png')
        shibie = Image.open('验证码.png')
        imgry = shibie.convert('L')
        table = [1] * 256
        for i in range(256):
            table[i] = 0
            if i > 115:
                break
        out = imgry.point(table, '1')
        out.show()
        box = (10, 10, 125, 45)
        out.crop(box)
        result = pytesseract.image_to_string(out)
        yanzheng = result.split(' ')
        first = yanzheng[0][0]
        last = len(yanzheng[-1])
        if last >= 3:
            lastnum=yanzheng[-1][-2:]
        else:
            lastnum=yanzheng[-1][-1]
        jieguo = int(lastnum) - int(first)
        print(jieguo)

    识别达到99%,另外的1%其实也是可以解决的,有时间再解决。

  • 相关阅读:
    用curl发起https请求
    curl: (60) SSL certificate problem: unable to get local issuer certificate 错误
    单例模式
    黑窗口命令
    推荐的php安全配置选项
    sublime配置大全
    数据库三范式最简单最易记的解释
    linux 下安装python3
    restframwork 接口及优化
    Django的orm练习---多表查询
  • 原文地址:https://www.cnblogs.com/542684416-qq/p/10904706.html
Copyright © 2020-2023  润新知