位置: 编程技术 - 正文

python下调用pytesseract识别某网站验证码的实现方法(python调用ch)

编辑:rootadmin

推荐整理分享python下调用pytesseract识别某网站验证码的实现方法(python调用ch),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:python调用pygame,Python下调用CH347DLL的方法,python调用pyd文件的方法,python 调用py,python调用pyc文件,python调用pyc文件,Python下调用CH347DLL的方法,python调用ch,内容如对您有帮助,希望把文章链接给更多的朋友!

一、pytesseract介绍

1、pytesseract说明

pytesseract最新版本0.1.6,网址: is a wrapper for google's Tesseract-OCR( ). It is also useful as astand-alone invocation script to tesseract, as it can read all image typessupported by the Python Imaging Library, including jpeg, png, gif, bmp, tiff,and others, whereas tesseract-ocr by default only supports tiff and bmp.Additionally, if used as a script, Python-tesseract will print the recognizedtext in stead of writing it to a file. Support for confidence estimates andbounding box data is planned for future releases.

翻译一下大意:

a、Python-tesseract是一个基于google's Tesseract-OCR的独立封装包;

b、Python-tesseract功能是识别图片文件中文字,并作为返回参数返回识别结果;

c、Python-tesseract默认支持tiff、bmp格式图片,只有在安装PIL之后,才能支持jpeg、gif、png等其他图片格式;

2、pytesseract安装

INSTALLATION:

Prerequisites:* Python-tesseract requires python 2.5 or later or python 3.* You will need the Python Imaging Library (PIL). Under Debian/Ubuntu, this isthe package "python-imaging" or "python3-imaging" for python3.* Install google tesseract-ocr from .You must be able to invoke the tesseract command as "tesseract". If thisisn't the case, for example because tesseract isn't in your PATH, you willhave to change the "tesseract_cmd" variable at the top of 'tesseract.py'.Under Debian/Ubuntu you can use the package "tesseract-ocr".

Installing via pip:

See the [pytesseract package page]( ```$> sudo pip install pytesseract

翻译一下:

a、Python-tesseract支持python2.5及更高版本;

b、Python-tesseract需要安装PIL(Python Imaging Library) ,来支持更多的图片格式;

c、Python-tesseract需要安装tesseract-ocr安装包。

python下调用pytesseract识别某网站验证码的实现方法(python调用ch)

综上,Pytesseract原理:

1、上一篇博文中提到,执行命令行 tesseract.exe 1.png output -l eng ,可以识别1.png中文字,并把识别结果输出到output.txt中;

2、Pytesseract对上述过程进行了二次封装,自动调用tesseract.exe,并读取output.txt文件的内容,作为函数的返回值进行返回。

二、pytesseract使用

USAGE:```> try:> import Image> except ImportError:> from PIL import Image> import pytesseract> print(pytesseract.image_to_string(Image.open('test.png')))> print(pytesseract.image_to_string(Image.open('test-european.jpg'), lang='fra'))

可以看到:

1、核心代码就是image_to_string函数,该函数还支持-l eng 参数,支持-psm 参数。

用法:

image_to_string(Image.open('test.png'),lang="eng" config="-psm 7")

2、pytesseract里调用了image,所以才需要PIL,其实tesseract.exe本身是支持jpeg、png等图片格式的。

实例代码,识别某公共网站的验证码(大家千万别干坏事啊,思虑再三,最后还是隐掉网站域名,大家去找别的网站试试吧……):

三、pytesseract代码优化

上述程序在windows平台运行时,会发现有黑色的控制台窗口一闪而过的画面,不太友好。

略微修改了pytesseract.py(C:PythonLibsite-packagespytesseract目录下),把上述过程进行了隐藏。

# modified by zhongtang hide console window# new codeIS_WIN = 'win' in str(sys.platform).lower()if IS_WIN: startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW startupinfo.wShowWindow = subprocess.SW_HIDE proc = subprocess.Popen(command, stderr=subprocess.PIPE,startupinfo=startupinfo)'''# old codeproc = subprocess.Popen(command, stderr=subprocess.PIPE)'''# modified end

为了方便初学者,把pytesseract.py也贴出来,高手自行忽略。

以上……

以上这篇python下调用pytesseract识别某网站验证码的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持积木网。

深入理解python函数递归和生成器 一、什么是递归如果函数包含了对其自身的调用,该函数就是递归的。递归做为一种算法在程序设计语言中广泛应用,它通常把一个大型复杂的问题层

深入浅析python定时杀进程 之前写了个python脚本用selenium+phantomjs爬新帖子,在循环拉取页面的过程中,phantomjs总是block住,使用WebDriverWait设置最长等待时间无效。用firefox替换phantom

Python的socket模块源码中的一些实现要点分析 BaseServer和BaseRequestHandlerPython为网络编程提高了更高级的封装。SocketServer.py提供了不少网络服务的类。它们的设计很优雅。Python把网络服务抽象成两个主

标签: python调用ch

本文链接地址:https://www.jiuchutong.com/biancheng/387576.html 转载请保留说明!

上一篇:浅析AST抽象语法树及Python代码实现(asoul抽象)

下一篇:深入理解python函数递归和生成器(python的了解)

  • 营改增抵减的销项税额会计分录
  • 工业产值是含税价格吗
  • 纳税人资格是什么意思
  • 消费税的会计分局
  • 小微企业税收优惠政策2023年房产税
  • 企业经营的范围怎么写
  • 个月所得税税率
  • 小规模纳税人涉税风险
  • 外资企业撤退
  • 现金日记账划线更正法
  • 收到投资款怎么做记账凭证
  • 餐饮行业打折部门是什么
  • 服务费和佣金的关系
  • 对方公司倒闭应收账款发票还需要开吗
  • 应交增值税转入其他流动资产
  • 银行对个人借款的处理
  • 免税商品销售要缴税吗
  • 商贸企业加工费票计入什么科目
  • 酒店的床和沙发哪个好
  • 资本弱化管理规定最新
  • linux怎么安装程序
  • led电子屏税收编码
  • 办妥托收手续会计分录
  • 社会保险费的征收程序
  • windows10无法打开此类型的文件(.exe)
  • 移动操作系统有哪些主要特点和功能
  • PHP:mb_ereg_search()的用法_mbstring函数
  • linux文件权限控制
  • win10系统宽带连接错误720
  • 电脑锁屏密码设置步骤
  • 支付给代理机构的手续费计入
  • 孕妇能吃荔枝吗 孕晚期
  • PHP:iconv_strrpos()的用法_iconv函数
  • 废旧物资发票抵扣
  • vue3响应式丢失
  • php curl爬虫
  • yolov5 anchors 中 K-means聚类
  • vue权限控制设计
  • 来料加工企业的划分标准
  • 技术服务型企业企业所得税率
  • 财政拨款结转的核算
  • java静态方法和动态方法的区别
  • 固定资产是价税合计吗
  • 个税赡养老人作废后无法修改
  • 汽车4s店售后业绩看板
  • 企业自产自用的产品需要缴纳增值税吗
  • 应付利息的账务处理
  • mysql的启动方法(windows 平台)
  • 实收资本库存现金凭证怎么开
  • 暂估入库跨年账务危险
  • 水处理设备行业发展
  • 应收账款提坏账分录
  • 核酸检测费用计入劳动保护费吗
  • 发票跨年红冲 交税
  • 付款退回在现金里怎么查
  • 月末忘记结转怎么办
  • 请演员的费用账务处理
  • 已核销的坏账又收回预算会计分录
  • 总公司中标分公司结算可以吗
  • 分公司费用报销
  • 工业企业应通过其他应付款科目核算的有
  • sqlserver 实现分组合并
  • mac桌面日历 记事本
  • .exe是什么软件
  • win8系统升级到win10东西还在吗
  • 苹果电脑快捷键截图怎么截
  • centos6启动不了
  • windows xp怎样禁止弹出广告
  • win10怎么把系统盘迁移到另一块盘
  • opensuse怎么安装软件
  • cocos2dx3.2 android平台APK打包
  • exec方法
  • bat调用vbs脚本
  • 创建简单的Web网页实验总结ASP
  • javascript create
  • 税务局要求补上年房租开票
  • 怎么绑定办税员
  • 湖南省税务局网站2024公务员招聘
  • 湖北省叉车考试题库
  • 四川残疾人社保补贴
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设