zoukankan      html  css  js  c++  java
  • 纯数字字符相加的验证码破解

    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%其实也是可以解决的,有时间再解决。

  • 相关阅读:
    Visual Studio 2010CTP的安装
    Crystal Reports中的数据访问
    Web.config配置文件详解1
    asp.net 面向对象方式的传值
    DataSet导出到Excel
    asp.net 身份验证
    Ini文件操作类
    asp.net环境下配置kindEditor文本编辑器
    验证视图状态 MAC 失败解决方法
    Web.config配置文件详解2
  • 原文地址:https://www.cnblogs.com/542684416-qq/p/10904706.html
Copyright © 2011-2022 走看看