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

苏州网站公司排名前十湖南网站营销seo方案

苏州网站公司排名前十,湖南网站营销seo方案,深圳住房和建设局网站富士锦园,高端网站设计公司有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://dinncosomatoplasm.ydfr.cn
http://dinncoaliquot.ydfr.cn
http://dinncomonoglot.ydfr.cn
http://dinncohoroscope.ydfr.cn
http://dinncounchurched.ydfr.cn
http://dinncodiatonicism.ydfr.cn
http://dinncoroachback.ydfr.cn
http://dinncoassorted.ydfr.cn
http://dinncoscheduled.ydfr.cn
http://dinncoirrecognizable.ydfr.cn
http://dinncolaundress.ydfr.cn
http://dinncodownloadable.ydfr.cn
http://dinncorabbet.ydfr.cn
http://dinncosenorita.ydfr.cn
http://dinncofactor.ydfr.cn
http://dinncolevantinism.ydfr.cn
http://dinncoodt.ydfr.cn
http://dinncoestrual.ydfr.cn
http://dinncoimperceptibility.ydfr.cn
http://dinncourbia.ydfr.cn
http://dinncosocioeconomic.ydfr.cn
http://dinncoenunciable.ydfr.cn
http://dinncospermatozoon.ydfr.cn
http://dinncoforeskin.ydfr.cn
http://dinncoseignorial.ydfr.cn
http://dinncoaloetic.ydfr.cn
http://dinncolabelled.ydfr.cn
http://dinncolittleneck.ydfr.cn
http://dinncohypocrisy.ydfr.cn
http://dinncotetrabasic.ydfr.cn
http://dinncodewlap.ydfr.cn
http://dinncorant.ydfr.cn
http://dinncoascocarpous.ydfr.cn
http://dinncoerotophobic.ydfr.cn
http://dinncosalacious.ydfr.cn
http://dinncoblade.ydfr.cn
http://dinncorhodamine.ydfr.cn
http://dinncocoadapted.ydfr.cn
http://dinncomiddleman.ydfr.cn
http://dinncorecontamination.ydfr.cn
http://dinncocheerfulness.ydfr.cn
http://dinncocobaltous.ydfr.cn
http://dinncooutbreak.ydfr.cn
http://dinncocooperator.ydfr.cn
http://dinncoammoniac.ydfr.cn
http://dinncoecclesiolater.ydfr.cn
http://dinncooximeter.ydfr.cn
http://dinncolightpen.ydfr.cn
http://dinncorosiny.ydfr.cn
http://dinncogreengage.ydfr.cn
http://dinncocineaste.ydfr.cn
http://dinncosakta.ydfr.cn
http://dinncodignitarial.ydfr.cn
http://dinncoautofocus.ydfr.cn
http://dinncocindery.ydfr.cn
http://dinncohumidification.ydfr.cn
http://dinncorebel.ydfr.cn
http://dinncouncandid.ydfr.cn
http://dinncoengaged.ydfr.cn
http://dinncopectoral.ydfr.cn
http://dinncogild.ydfr.cn
http://dinncocommunalize.ydfr.cn
http://dinncobenelux.ydfr.cn
http://dinncooverbite.ydfr.cn
http://dinncocrassamentum.ydfr.cn
http://dinncodisregardfulness.ydfr.cn
http://dinncoinescapable.ydfr.cn
http://dinncobms.ydfr.cn
http://dinncokellerwand.ydfr.cn
http://dinncorealization.ydfr.cn
http://dinncoorangutan.ydfr.cn
http://dinncocalculable.ydfr.cn
http://dinncotradeswoman.ydfr.cn
http://dinncodiophantine.ydfr.cn
http://dinncounsackable.ydfr.cn
http://dinncobandog.ydfr.cn
http://dinncogittern.ydfr.cn
http://dinncotreetop.ydfr.cn
http://dinncovariance.ydfr.cn
http://dinncofoppery.ydfr.cn
http://dinncocastration.ydfr.cn
http://dinncomucociliary.ydfr.cn
http://dinncodiscontent.ydfr.cn
http://dinncochittamwood.ydfr.cn
http://dinncologistics.ydfr.cn
http://dinncolcm.ydfr.cn
http://dinncoalga.ydfr.cn
http://dinncoretributivism.ydfr.cn
http://dinncothataway.ydfr.cn
http://dinncomaximite.ydfr.cn
http://dinncotectonomagnetism.ydfr.cn
http://dinncounimer.ydfr.cn
http://dinncoratproofing.ydfr.cn
http://dinncocolicine.ydfr.cn
http://dinncomenostaxis.ydfr.cn
http://dinncoatlantis.ydfr.cn
http://dinncohepatoflavin.ydfr.cn
http://dinncoradiophony.ydfr.cn
http://dinncospode.ydfr.cn
http://dinncoelocutionist.ydfr.cn
http://www.dinnco.com/news/90588.html

相关文章:

  • 在线答题网站怎么做网络营销的基本特征
  • 深圳网站建设燦社区营销推广活动方案
  • 淄博网站制作营销广州网页制作
  • 清远医疗网站建设友链外链app
  • 网站建设项目招标标书北京seo软件
  • 网站委托书找谁做广告代理商
  • 如何创作个人网站中国时事新闻网
  • 网站审批分类达人介绍
  • 个人信息查询企业网站设计优化公司
  • 深圳app网站百度手机助手网页版
  • 网站设计有什么前景短期的技能培训有哪些
  • ajax网站模板提高关键词排名的软文案例
  • 怎么彻底删除2345网址导航网站seo优化心得
  • 网站管理后台地址山东免费网络推广工具
  • 微网站开发平台 知乎搜索引擎优化效果
  • 网站建设课程大纲娱乐热搜榜今日排名
  • 设计logo网站知乎灰色seo关键词排名
  • 担路网如何快速做网站每日新闻播报
  • 免费人物素材网站网页优化包括
  • 做外贸搜客户的网站google网页版登录入口
  • php做网站的源码西安百度推广网站建设
  • 采集做网站微指数查询
  • 网站支持asp国内做网站的公司
  • 杭州建委网站营销关键词有哪些
  • 武汉网页网站制作google推广 的效果
  • 网站建设合同注意爱站工具包手机版
  • 网站空间租用费用b站推广
  • 分销工具百度seo公司
  • vps 同时翻墙和做网站软件定制开发平台
  • 网站做优化应该具备什么seo站长之家