python使用 pytesseract + tesseract-ocr 进行验证码识别

使用 pytesseract + tesseract-ocr 进行验证码识别,需要安装的第三方库:pytesseract 、tesseract-ocr,在使用pytesseract 之前,必须安装tesseract-ocr,因为 pytesseract 依赖于tesseract-ocr,否则无法使用。

1、tesseract-ocr下载安装与配置:tesseract-ocr下载安装与配置

2、pytesseract 安装:pip install pytesseract

3、修改pytesseract.py脚本

在python的安装目录下找到pytesseract 的安装路径,在pytesseract 文件夹下的pytesseract.py脚本中,用记事本打开pytesseract.py,通过ctrl+f快速搜索功能定位tesseract_cmd,修改后面的文件路径。

4、用pytesseract识别验证码

1
2
3
4
5
6
7
8
9
10
from PIL import Image
import pytesseract
 
# 用pytesseract识别验证码
# 1:打开需要识别的图片
image = Image.open(r'image\code.png')
# 2:pytesseract识别为字符串
code = pytesseract.image_to_string(image)
# 3:输出识别的内容
print(code)

posted @   岁月淡忘了谁  阅读(1074)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
历史上的今天:
2021-03-18 vue动态配置参数,避免重复打包
2021-03-18 export报错SyntaxError: Unexpected token export
2021-03-18 windows下安装和配置Redis
2020-03-18 工具连接
点击右上角即可分享
微信分享提示