位置: 编程技术 - 正文

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

  • 小规模纳税人收入是含税还是不含税
  • 出售投资性房地产取得的收入
  • 工程建设期间发生的业务招待费
  • 会计信息采集每年都要采集吗
  • 劳务公司劳务工资做什么科目
  • 湖北省异地预缴增值税
  • 小规模纳税人印花税减免税优惠政策
  • 增值税怎样报税
  • 接受现金捐赠怎么写分录
  • 不动产可以拆吗
  • 增值税专用发票和普通发票的区别
  • 缴纳印花税需要计提吗?
  • 销售货物类型
  • 公司低价卖房土地增值税计税方法是什么
  • 个人购买房屋的税
  • 接受无形资产投资进项税
  • 企业筹建期的工会金费怎么入账
  • 买东西退税退的是什么税
  • 生产企业低值高报骗税
  • 天猫技术服务费什么时候返还
  • 出口退税的账务关键是什么
  • 发票已认证但是没申报跨年度了怎么办
  • 新版edge浏览器极速模式
  • 苹果电脑删除win系统文件
  • linux怎么操作
  • win10玩游戏fps低怎么办
  • win7怎么更改开机启动项
  • 分次发放年终奖怎么做账
  • 酒店购进布草可直接确认为成本吗
  • 独立费用包括
  • 利润表项目本期怎么算
  • 单位管理费用核算范围包括
  • 购买支票费用计入
  • 公司注销账面实收资本如何处理
  • vue 动态样式
  • php功能实现
  • python的series
  • 残保金缴纳需要计提吗
  • 购买房屋用于出租属于投资行为吗
  • 小规模纳税人可以做进出口贸易吗
  • 房地产按揭贷款政策
  • 钢管扣件租赁公司账务处理
  • 残疾人个人所得税扣除
  • 银行抵债资产如何更快处置
  • 税负率偏低
  • 收到房租费发票如何做账
  • 城镇土地使用税减免税政策
  • 在企业中的应用
  • 建筑业分包税收政策
  • 预付工资怎么入账
  • centos7.6怎么安装
  • dnfxp系统能玩吗
  • ubuntu系统如何安装qq
  • elf.exe是什么程序
  • linux怎么使用ping命令
  • dl是什么文件
  • mcclauncher.exe
  • centos删除vg
  • win10粘滞键怎么解除
  • win8无法安装net4.7
  • 网页使用的字体中最具可读性.最易浏览的是
  • css div高度填满父容器剩余空间
  • opengl绘制坐标轴
  • 微信小程序基于spingboot
  • 全面了解中国历史英文
  • vue设置背景图片全屏
  • 数据结构 二叉树什么是孩子数
  • vue动态路由传参
  • shell脚本总结
  • cmd命令format
  • python内置数据结构有几种
  • 老生常谈的近义词
  • unity-
  • js实现字符串和数字对齐
  • js 数组处理
  • jquery插件库怎么导入
  • python优先级顺序
  • JavaScript程序设计形考任务第一次任务
  • 广东电子税务局app
  • 四川农村信用社电话
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设