位置: 编程技术 - 正文

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的了解)

  • 提足折旧是指
  • 部分产品退货怎么办
  • 自然人独资公司和个人独资企业区别
  • 公司注销公司帐户剩的钱怎么办
  • 广告业务增值税税率
  • 企业报税盘入账应该记入哪个科目
  • 核算科目拨出专票怎么弄
  • 记账凭证填制流程是什么
  • 筹资活动现金流量净额为负
  • 增资扩股如何操作
  • 招待费进项税如何抵扣
  • 小规模纳税人附加税税率各是多少
  • 普通发票打歪了可以用吗
  • 一般纳税人销售自己使用过的物品
  • 应纳税所得额应纳税额公式
  • 公司支付个人劳务
  • 多交的增税怎么做账
  • 一般纳税人购车可以抵扣多少税
  • 2018年工资薪金个税起征点
  • 处理固定资产怎么计算
  • 企业微信收入也要交税吗
  • 如何编制处置固定资产
  • 拍卖公司财务
  • w10系统安装office
  • 华为mate50 pro
  • 发票已经认证,发现错误了要怎么处理
  • 净损益是
  • dvd.rom
  • 城建税教育费附加和地方教育费附加税率
  • 结转结余会计分录
  • 短期投资计入什么科目
  • 计提本月固定资产折旧,其中车间折旧额1100
  • php 命名空间
  • 现金流量表补充资料怎么理解
  • 程序人是什么意思
  • php构造函数重载
  • 数据库如何迁移数据库表
  • 省外的发票能入账吗
  • 应交税费的进项税和销项税
  • 专项应付款二级明细科目有哪些
  • list删除某个元素 python
  • 企业在计提短期借款利息时可能用到的会计科目有
  • 企业应收账款的规模受哪些因素的影响?( )
  • 归还股东投资款
  • 资产损失税前扣除最新政策2021
  • 出租车公共服务
  • 生育津贴现在可以打个人账户么
  • sql语句清空表中数据
  • 计提坏账准备的方法
  • 进项税准予抵扣条件有哪些
  • 应付账款冲减会计分录
  • 银行支付结算管理办法
  • 现金支票存根联和正联怎么盖章
  • 从个人处借款的会计分录
  • 生产成本福利费如何分摊
  • 单位统一订员工餐
  • 小规模一季度不超过30万是不含税吗
  • 联营公司是关联方吗
  • 人工成本包括哪些项目
  • win8 preparing automatic repair
  • Ubuntu安装ssh
  • Linux系统中修改文件权限
  • Win10 Mobile RS2预览版14915上手视频评测
  • win10如何打开defender
  • css全局声明
  • Node.js中的什么模块是用于处理文件和目录的
  • 安卓开发viewpager的用法
  • unity点击3d物体
  • Clipboard.js 无需Flash的JavaScript复制粘贴库
  • javascript基础笔记
  • python数据类型有什么用
  • js如何实现类的继承
  • python爬虫有道翻译
  • 国家税务局发票查询
  • 北京税务师取消了吗
  • 银川到大武口的汽车站时刻表
  • 竣工开始缴房产税吗
  • 西安税务总局
  • 美国海外公司每年利润
  • 2018年申报时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设