需要ocr识别网站验证码,推荐Python免费的验证码识别-ddddocr
环境:Python 3.8.10 64 bit (AMD64)] on win32,Visual Studio 2019社区版
工具:PyCharm Community Edition 2021.2.3
1、安装ddddocr
运行命令:pip install ddddocr (https://github.com/sml2h3/ddddocr)
2、验证码图片
import ddddocrocr = ddddocr.DdddOcr()with open('./yzm/slogin.jpg', 'rb') as f: image_bytes = f.read()res = ocr.classification(image_bytes)print(res)
1085
报错笔记:
1、没有安装Visual Studio 2019社区版之前,import ddddocr会报错,提示ImportError: DLL load failed while importing onnxruntime_pybind11_state,百度搜索各种方法均没有解决报错问题;
2、使用IDLE输入import onnxruntime,报错提示warnings.warn("Please install the 2019 Visual C++ runtime and then try again");
3、链接:https://docs.microsoft.com/zh-CN/visualstudio/releases/2019/redistribution#vs2019-download下载Visual Studio 2019社区版,选择“使用C++的桌面开发”并确保安装详细信息的前两项勾选即可。
4、安装完毕后重新运行代码成功执行。