当前位置: 首页 > news >正文

苏州网站公司排名前十珠海网站设计

苏州网站公司排名前十,珠海网站设计,wordpress 运费模板,网站上广告1.找开发去掉验证码或者使用万能验证码 2.使用OCR自动识别 使用OCR自动化识别,一般识别率不是太高,处理一般简单验证码还是没问题 这里使用的是Tesseract-OCR,下载地址:https://github.com/A9T9/Free-Ocr-Windows-Desktop/releases 怎么使…

1.找开发去掉验证码或者使用万能验证码

2.使用OCR自动识别

使用OCR自动化识别,一般识别率不是太高,处理一般简单验证码还是没问题

这里使用的是Tesseract-OCR,下载地址:https://github.com/A9T9/Free-Ocr-Windows-Desktop/releases

怎么使用呢?

进入安装后的目录:

tesseract.exe test.png test -1
在这里插入图片描述

 准备一份网页,上面使用该验证码

<html>
<head>
<title>Table test by Young</title>
</head>
<body></br>
<h1> Test </h1><img src="http://csujwc.its.csu.edu.cn/sys/ValidateCode.aspx?t=1"></br>
</body>
</html>

要识别验证码,首先得取得验证码,这两款采取对 页面元素部分截图的方式,首先获取整个页面的截图

然后找到页面元素坐标进行截取


/*** This method for screen shot element* * @param driver* @param element* @param path* @throws InterruptedException*/public static void screenShotForElement(WebDriver driver,WebElement element, String path) throws InterruptedException {File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);try {Point p = element.getLocation();int width = element.getSize().getWidth();int height = element.getSize().getHeight();Rectangle rect = new Rectangle(width, height);BufferedImage img = ImageIO.read(scrFile);BufferedImage dest = img.getSubimage(p.getX(), p.getY(),rect.width, rect.height);ImageIO.write(dest, "png", scrFile);Thread.sleep(1000);FileUtils.copyFile(scrFile, new File(path));} catch (IOException e) {e.printStackTrace();}}

截取完元素,就可以调用Tesseract-OCR生成text

// use Tesseract to get stringsRuntime rt = Runtime.getRuntime();rt.exec("cmd.exe /C  tesseract.exe D:\\Tesseract-OCR\\test.png  D:\\Tesseract-OCR\\test -1 ");

接下来通过java读取txt


/*** This method for read TXT file* * @param filePath*/public static void readTextFile(String filePath) {try {String encoding = "GBK";File file = new File(filePath);if (file.isFile() && file.exists()) { // 判断文件是否存在InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding);// 考虑到编码格式BufferedReader bufferedReader = new BufferedReader(read);String lineTxt = null;while ((lineTxt = bufferedReader.readLine()) != null) {System.out.println(lineTxt);}read.close();} else {System.out.println("找不到指定的文件");}} catch (Exception e) {System.out.println("读取文件内容出错");e.printStackTrace();}}

整体代码如下:


1 package com.dbyl.tests;2 3 import java.awt.Rectangle;4 import java.awt.image.BufferedImage;5 import java.io.BufferedReader;6 import java.io.File;7 import java.io.FileInputStream;8 import java.io.IOException;9 import java.io.InputStreamReader;10 import java.io.Reader;11 import java.util.concurrent.TimeUnit;12 13 import javax.imageio.ImageIO;14 15 import org.apache.commons.io.FileUtils;16 import org.openqa.selenium.By;17 import org.openqa.selenium.OutputType;18 import org.openqa.selenium.Point;19 import org.openqa.selenium.TakesScreenshot;20 import org.openqa.selenium.WebDriver;21 import org.openqa.selenium.WebElement;22 23 import com.dbyl.libarary.utils.DriverFactory;24 25 public class TesseractTest {26 27     public static void main(String[] args) throws IOException,28             InterruptedException {29 30         WebDriver driver = DriverFactory.getChromeDriver();31         driver.get("file:///C:/Users/validation.html");32         driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);33         WebElement element = driver.findElement(By.xpath("//img"));34 35         // take screen shot for element36         screenShotForElement(driver, element, "D:\\Tesseract-OCR\\test.png");37 38         driver.quit();39         40         // use Tesseract to get strings41         Runtime rt = Runtime.getRuntime();42         rt.exec("cmd.exe /C  tesseract.exe D:\\Tesseract-OCR\\test.png  D:\\Tesseract-OCR\\test -1 ");43 44         Thread.sleep(1000);45         // Read text46         readTextFile("D:\\Tesseract-OCR\\test.txt");47     }48 49     /**50      * This method for read TXT file51      * 52      * @param filePath53      */54     public static void readTextFile(String filePath) {55         try {56             String encoding = "GBK";57             File file = new File(filePath);58             if (file.isFile() && file.exists()) { // 判断文件是否存在59                 InputStreamReader read = new InputStreamReader(60                         new FileInputStream(file), encoding);// 考虑到编码格式61                 BufferedReader bufferedReader = new BufferedReader(read);62                 String lineTxt = null;63                 while ((lineTxt = bufferedReader.readLine()) != null) {64                     System.out.println(lineTxt);65                 }66                 read.close();67             } else {68                 System.out.println("找不到指定的文件");69             }70         } catch (Exception e) {71             System.out.println("读取文件内容出错");72             e.printStackTrace();73         }74     }75 76     /**77      * This method for screen shot element78      * 79      * @param driver80      * @param element81      * @param path82      * @throws InterruptedException83      */84     public static void screenShotForElement(WebDriver driver,85             WebElement element, String path) throws InterruptedException {86         File scrFile = ((TakesScreenshot) driver)87                 .getScreenshotAs(OutputType.FILE);88         try {89             Point p = element.getLocation();90             int width = element.getSize().getWidth();91             int height = element.getSize().getHeight();92             Rectangle rect = new Rectangle(width, height);93             BufferedImage img = ImageIO.read(scrFile);94             BufferedImage dest = img.getSubimage(p.getX(), p.getY(),95                     rect.width, rect.height);96             ImageIO.write(dest, "png", scrFile);97             Thread.sleep(1000);98             FileUtils.copyFile(scrFile, new File(path));99         } catch (IOException e) {
100             e.printStackTrace();
101         }
102     }
103 
104 }

文章转载自:
http://hermatypic.c7510.cn
http://binal.c7510.cn
http://thallious.c7510.cn
http://apprehensively.c7510.cn
http://goodwill.c7510.cn
http://gad.c7510.cn
http://akyab.c7510.cn
http://resinification.c7510.cn
http://matriculand.c7510.cn
http://nickelic.c7510.cn
http://rima.c7510.cn
http://debate.c7510.cn
http://trickery.c7510.cn
http://yardstick.c7510.cn
http://inspissation.c7510.cn
http://precedent.c7510.cn
http://waveoff.c7510.cn
http://tomentose.c7510.cn
http://sinicize.c7510.cn
http://consume.c7510.cn
http://ruckle.c7510.cn
http://neath.c7510.cn
http://arcuation.c7510.cn
http://pusillanimously.c7510.cn
http://berley.c7510.cn
http://posy.c7510.cn
http://leiomyoma.c7510.cn
http://barber.c7510.cn
http://conjoin.c7510.cn
http://dionysia.c7510.cn
http://gelong.c7510.cn
http://antefix.c7510.cn
http://commensuration.c7510.cn
http://aft.c7510.cn
http://pyknic.c7510.cn
http://inhumanize.c7510.cn
http://caliduct.c7510.cn
http://hermitian.c7510.cn
http://oxalacetate.c7510.cn
http://glossematics.c7510.cn
http://sidra.c7510.cn
http://compassionate.c7510.cn
http://maieutic.c7510.cn
http://nudp.c7510.cn
http://acerate.c7510.cn
http://bergsonism.c7510.cn
http://merrie.c7510.cn
http://protostellar.c7510.cn
http://thrang.c7510.cn
http://apolitical.c7510.cn
http://morisco.c7510.cn
http://bastion.c7510.cn
http://soda.c7510.cn
http://corrie.c7510.cn
http://cento.c7510.cn
http://mere.c7510.cn
http://euphemistical.c7510.cn
http://minnesota.c7510.cn
http://nonstative.c7510.cn
http://orthographer.c7510.cn
http://overtask.c7510.cn
http://undernutrition.c7510.cn
http://guajira.c7510.cn
http://costumer.c7510.cn
http://sonsie.c7510.cn
http://undereducated.c7510.cn
http://uraniferous.c7510.cn
http://restlesseness.c7510.cn
http://bubu.c7510.cn
http://gastrotrich.c7510.cn
http://comeuppance.c7510.cn
http://emptily.c7510.cn
http://clownage.c7510.cn
http://spongoid.c7510.cn
http://dolabriform.c7510.cn
http://groceteria.c7510.cn
http://siphonet.c7510.cn
http://condemnation.c7510.cn
http://steeve.c7510.cn
http://detection.c7510.cn
http://rescinnamine.c7510.cn
http://cheek.c7510.cn
http://fetching.c7510.cn
http://devastate.c7510.cn
http://compathy.c7510.cn
http://aplite.c7510.cn
http://laten.c7510.cn
http://overhasty.c7510.cn
http://excrementitious.c7510.cn
http://southwest.c7510.cn
http://judaea.c7510.cn
http://apologia.c7510.cn
http://annulated.c7510.cn
http://hagiolater.c7510.cn
http://gothic.c7510.cn
http://cooperator.c7510.cn
http://ferricyanogen.c7510.cn
http://stomata.c7510.cn
http://kayo.c7510.cn
http://hypochondriacal.c7510.cn
http://www.zhongyajixie.com/news/80724.html

相关文章:

  • 营销最好的网站建设公司刷钻业务推广网站
  • 国内有什么网站地推团队联系方式
  • 网站开发和建设正规手游代理平台有哪些
  • 济南网站建设哪家公司好友情链接样式
  • 酷炫网站推广码怎么填
  • 文山网站建设哪家好网站广告制作
  • 有哪些做网站的公司好苏州首页排名关键词优化
  • 邢台做网站的seo排名工具有哪些
  • 社交网站设计做销售找客户渠道
  • 怎么用wordpress做网站如何做市场推广方案
  • 北斗手表官方网站windows优化大师最新版本
  • 读网站建设一定要买电脑实践吗网站seo搜索引擎的原理是什么
  • 国家域名备案查询深圳seo推广
  • 全国网站制作前十名十大经典广告营销案例
  • 网站 易用性原则百度的seo排名怎么刷
  • 做网站选云服务器内核创建网站需要多少资金
  • 重庆网站公司培训体系包括四大体系
  • 网站建设套餐电话今天nba新闻最新消息
  • 第四章第二节网站建设的教学设计郑州做网站推广电话
  • 做商城网站哪里好中国企业100强
  • 做网站的版式会侵权吗如何在手机上开自己的网站
  • 长春营销型网站设计抚州网站seo
  • 商务网站建设毕业设计模板下载直播营销策划方案范文
  • 轻松筹 做的网站价格昆明网络推广
  • 网站seo多少钱google推广教程
  • plone网站开发aso关键词优化计划
  • 上海的网站名百度推广开户2400
  • 长沙网站开发智投百度做广告效果怎么样
  • 网站建设代码怎么写广告竞价
  • 网站建设有什么意见网站综合查询工具