0. Ubuntu 14.10已经安装了Python2.7,所以无需额外安装python了
1. 安装pip:sudo apt-get install python-pip
2. 安装selenium:sudo pip install -U selenium
3. 验证是否安装成功:
a. 打开终端,打开python命令行
b. from selenium import webdriver
c. driver = webdriver.Firefox(); driver.get("http://www.baidu.com")
d. 此时应该打开Firefox浏览器,并打开百度的主页面
4. pytester、tesseract
a. 安装所需的库 sudo apt-get install libpng12-dev sudo apt-get install libjpeg62-dev sudo apt-get install libtiff5-dev sudo apt-get install gcc sudo apt-get install g++ sudo apt-get install automake b. pytesser 调用了 tesseract,因此需要安装 tesseract,安装 tesseract 需要安装 leptonica,否则编译tesseract 的时候出现 "configure: error: leptonica not found"。 c. 所以要先下载安装leptonica,http://www.leptonica.org/download.html 或者http://code.google.com/p/leptonica/downloads/list最新的是leptonica-1.71.tar.gz d. 下载安装tesseract,http://code.google.com/p/tesseract-ocr/, 最新的是 tesseract-ocr-3.02.02.tar.gz e. 安装leptonica和tesseract ./configure make -j4 sudo make install f. 下载安装 tesseract 的语言数据包,http://code.google.com/p/tesseract-ocr/downloads/list,最新的是 tesseract-ocr-3.02.eng.tar.gz, 解压tessdata目录下的文件(9个)到 "/usr/local/share/tessdata"目录下 g. 下载安装 pytesser,http://code.google.com/p/pytesser/, 最新的是 pytesser_v0.0.1.zip,直接解压就能使用
5. 测试pytesser,到pytesser的安装目录,创建一个test.py,python test.py 查看结果,tesseract 目录还有其他tif文件,也可以复制过来测试,上面测试的tif,png文件正确识别出文字。
from pytesser import * #im = Image.open('fnord.tif') im = Image.open('phototest.tif') #im = Image.open('eurotext.tif') #im = Image.open('fonts_test.png') text = image_to_string(im) print text
6. pytesser的验证码识别能力较低,只能对规规矩矩不歪不斜数字和字母验证码进行识别。测试了几个网站的验证码,显示 Empty page,看来用它来识别验证码是无望了。
测试发现提高对比度后再识别有助于提高识别准确率。
enhancer = ImageEnhance.Contrast(im) im = enhancer.enhance(4)
7. 错误记录:
a. 遇到这个错误: $ tesseract foo.png bar tesseract: error while loading shared libraries: libtesseract_api.so.3 cannot open shared object file: No such file or directory You need to update the cache for the runtime linker. The following should get you up and running: $ sudo ldconfig b. tesseract安装成功的提示: www@Kylin:~/code/python/pytesser$ tesseract Usage:tesseract imagename outputbase [-l lang] [-psm pagesegmode] [configfile...] pagesegmode values are: 0 = Orientation and script detection (OSD) only. 1 = Automatic page segmentation with OSD. 2 = Automatic page segmentation, but no OSD, or OCR 3 = Fully automatic page segmentation, but no OSD. (Default) 4 = Assume a single column of text of variable sizes. 5 = Assume a single uniform block of vertically aligned text. 6 = Assume a single uniform block of text. 7 = Treat the image as a single text line. 8 = Treat the image as a single word. 9 = Treat the image as a single word in a circle. 10 = Treat the image as a single character. -l lang and/or -psm pagesegmode must occur before anyconfigfile. Single options: -v --version: version info --list-langs: list available languages for tesseract engine
8. 需要自己下载的软件包都在附件中,其中tesseract-ocr-3.02.eng.zip有12M,超出了iteye附件不超过10M的规定,所以没有上传。
相关推荐
python爬虫教程,带你从零到一,包含js逆向,selenium, tesseract OCR识别,mongodb
本篇文章主要介绍了Python+Selenium+PIL+Tesseract自动识别验证码进行一键登录,具有一定的参考价值,有兴趣的可以了解下
亲测有效,ubuntu16.04上安装及使用selenium、chrome、chromedriver
python使用selenium和tesseract来获取电影评分总目录工具需求爬取原理安装第三方库上代码结果图写在最后 总目录 使用python来爬取网页信息经常遇到反爬,对于一些加密的信息更是难搞,下载.woff之类的文件再解码对于...
火狐Firefox浏览器安装Selenium_IDE的步骤
selenium是自动化测试的必备工具,由于selenium IDE官网打不开,所以我在这里找了离线包并做了离线安装教程。
简单的selenium开发流程是: 1. 打开firefox,打开seleniumIDE进行脚本录制和回放,调试的时候可能需要firebug插件查看页面中的对象; 2. 生成junit4的java代码后,导入eclipse的java工程中,启动seleniumRC,然后...
python+selenium 安装
主要介绍了详解python环境安装selenium和手动下载安装selenium的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
用python安装selenium(selenium是提前下载的安装包,当然也可以网络安装,网络安装会自动安装最新版本。.目前使用的是selenium-3.12.0) 但是安装selenium时报如下错误: pip install selenium-3.12.0-py2.py3-none-...
开始学习爬虫,但是在第一天就遇到了大问题,在命令行安装selenium一直提示下列SSL有问题:WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available...
python的selenium安装,自动化测试必备初级教程,包含各大浏览器的安装步骤,十分详细,非网上 down下来的那种,是纯手工打造,亲测可用
python pandas selenium geckodriver ie、Firefox、chrome等
简单的selenium开发流程是: 1. 打开firefox,打开seleniumIDE进行脚本录制和回放,调试的时候可能需要firebug插件查看页面中的对象; 2. 生成junit4的java代码后,导入eclipse的java工程中,启动seleniumRC,然后...
这篇文章主要介绍了python识别文字(基于tesseract)代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 Ubuntu版本: 1.tesseract-ocr安装 sudo apt-get...
安装selenium webdriver 安装ruby1.8.7或1.9.2。注意selenium-webdriver只支持1.8.7以上的ruby版本; 使用gem安装selenium-webdriver;打开命令行,输入下列代码完成安装。注意,如果你的开发环境需要http proxy...
selenium+firefox+eclipse+pydev安装
selenium安装教程,详细讲解如何安装selenium,对测试人员很有帮助
Selenium_v2.5 Selenium_v2.5 Selenium_v2.5 Selenium_v2.5Selenium_v2.5 Selenium_v2.5