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

百度企业云网站建设天津天狮网络营销课程

百度企业云网站建设,天津天狮网络营销课程,有培训做网站 小程序的学校,web简单网页设计参考链接 1、需要下载Tesseract工具并配置环境变量&#xff0c;步骤如下 Tesseract-OCR 下载安装和使用_tesseract-ocr下载-CSDN博客 2、需要在IDEA中导入tess4j 包&#xff1b;在pom.xml文件中输入如下内容 <!--导入Tesseract 用于识别验证码--><dependency>&l…

参考链接

1、需要下载Tesseract工具并配置环境变量,步骤如下

Tesseract-OCR 下载安装和使用_tesseract-ocr下载-CSDN博客

2、需要在IDEA中导入tess4j 包;在pom.xml文件中输入如下内容

        <!--导入Tesseract 用于识别验证码--><dependency><groupId>net.sourceforge.tess4j</groupId><artifactId>tess4j</artifactId><version>4.5.4</version></dependency>

3、查看本地电脑是否有Microsoft VisualC++2019 如果没有则需要下载不然运行代码时会出现‘无法找到指定模块’的报错

如果没有的话下载链接如下:
Microsoft Visual C++ 2019等其他版本下载链接-CSDN博客

4、当将上面的步骤中的配置完成后,那么就可以敲代码了。首选需要打开网站

driver = ChromeDriverConfig.getChromeDriver();//调用驱动类方法获取驱动对象driver.get("https://www.baidu.com");//打开网站driver.manage().window().maximize();//窗口最大化String KyxUrl=driver.getCurrentUrl();System.out.println("获取打开界面链接地址是"+KyxUrl);Assert.assertEquals(KyxUrl,"https://www.baidu.com","地址不同");

5、打开网站后截取整个界面,并将截取下的图片保存在指定目录中,代码如下

概步骤是为了做个验证 查看获取的验证码图片是否正确,加不加都行,重点是获取验证码的图片

try {//截取当前屏幕内容,并保存到本地File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);//将截取下来的图片保存到指定目录并指定文件名// D:\Program Files\IntelliJ IDEA 2023.3.2\NewMedia\imgTest\01.png  File pathFile = new File("D:\\Program Files\\IntelliJ IDEA 2023.3.2\\NewMedia\\imgTest\\01.png");if (pathFile.exists()) {//判断文件是否存在pathFile.delete();//如果文件存在则删除}//将屏幕截图移动到指定目录FileUtils.moveFile(screenshot, new File("D:\\Program Files\\IntelliJ IDEA 2023.3.2\\NewMedia\\imgTest\\01.png"));} catch (IOException e) {e.printStackTrace();}

6、如图所示,验证码的html标签显示如下,可以通过xpath中

By.tagName("img")来定位到验证码图片。

定位到图片后,下载二维码图片到指定目录,并通过下载的Tessercat来对验证码图片进行读取并将文本内容输出为字符串。具体代码如下:

//定义图片存放路径包括文件名String eleLocalFileFullName = "D:\\Program Files\\IntelliJ IDEA 2023.3.2\\NewMedia\\imgTest\\Test.png";//本地文件转为文件类型File eleLocalFile = new File(eleLocalFileFullName);//通过By.tagName("img")定位验证码图片位置WebElement captchaImg = driver.findElement(By.tagName("img"));//截取二维码图片并下载到本地默认目录File eleScreenShotFile = captchaImg.getScreenshotAs(OutputType.FILE);//判断指定目录中Test.png是否存在如果存在则删除if(eleLocalFile.exists()){eleLocalFile.delete();}//将本地默认路径中的验证码截图文件移动到指定目标FileUtils.moveFile(eleScreenShotFile, eleLocalFile);//实例化ITesseractITesseract tesseract = new Tesseract();// 设置 Tesseract 数据路径,这里需要指向 tessdata 文件夹tesseract.setDatapath("D:/Program Files/Tesseract-OCR/tessdata");try{// 设置识别语言,eng默认为英文,中文简体设置为"chi_sim"tesseract.setLanguage("eng");//读取本地图片文件// 读取本地图片文件String pathToImageFile = "D:/Program Files/IntelliJ IDEA 2023.3.2/NewMedia/imgTest/Test.png";File imageFile = new File(pathToImageFile);// 执行OCR识别String ocrResult = tesseract.doOCR(imageFile);// 输出识别结果System.out.println(ocrResult);}catch (TesseractException e){e.printStackTrace();}


文章转载自:
http://ametoecious.rpms.cn
http://oenology.rpms.cn
http://madbrain.rpms.cn
http://skepticize.rpms.cn
http://teeming.rpms.cn
http://cruces.rpms.cn
http://amebocyte.rpms.cn
http://juicy.rpms.cn
http://outrageous.rpms.cn
http://fibrositis.rpms.cn
http://viremia.rpms.cn
http://committeewoman.rpms.cn
http://involute.rpms.cn
http://gpf.rpms.cn
http://digitizer.rpms.cn
http://assassination.rpms.cn
http://huhehot.rpms.cn
http://be.rpms.cn
http://lavender.rpms.cn
http://microphonics.rpms.cn
http://anisette.rpms.cn
http://espresso.rpms.cn
http://geist.rpms.cn
http://scherzo.rpms.cn
http://rebaptism.rpms.cn
http://stickiness.rpms.cn
http://eurythermal.rpms.cn
http://disamenity.rpms.cn
http://descendant.rpms.cn
http://isotopy.rpms.cn
http://unaccepted.rpms.cn
http://amphibrach.rpms.cn
http://cataleptiform.rpms.cn
http://glaciation.rpms.cn
http://bidden.rpms.cn
http://zymase.rpms.cn
http://squeteague.rpms.cn
http://engraphia.rpms.cn
http://smallpox.rpms.cn
http://marchioness.rpms.cn
http://applicative.rpms.cn
http://imperfectible.rpms.cn
http://bemoan.rpms.cn
http://weatherboarding.rpms.cn
http://unpitied.rpms.cn
http://inwrought.rpms.cn
http://wronghead.rpms.cn
http://minor.rpms.cn
http://xeroderma.rpms.cn
http://daruma.rpms.cn
http://perborax.rpms.cn
http://volutin.rpms.cn
http://henhearted.rpms.cn
http://lessen.rpms.cn
http://fraise.rpms.cn
http://biparasitic.rpms.cn
http://complexity.rpms.cn
http://penetralia.rpms.cn
http://cunningly.rpms.cn
http://supercede.rpms.cn
http://valedictory.rpms.cn
http://tongueless.rpms.cn
http://famed.rpms.cn
http://conductibility.rpms.cn
http://electrojet.rpms.cn
http://usumbura.rpms.cn
http://nondrying.rpms.cn
http://seichometer.rpms.cn
http://frazzle.rpms.cn
http://incendivity.rpms.cn
http://criterion.rpms.cn
http://inclemency.rpms.cn
http://babelize.rpms.cn
http://nucleolate.rpms.cn
http://crisco.rpms.cn
http://concretization.rpms.cn
http://kwangchow.rpms.cn
http://juxtaterrestrial.rpms.cn
http://annihilate.rpms.cn
http://oxycalcium.rpms.cn
http://komondor.rpms.cn
http://consentient.rpms.cn
http://galleta.rpms.cn
http://skirt.rpms.cn
http://detoxicator.rpms.cn
http://drupaceous.rpms.cn
http://reunionist.rpms.cn
http://deadborn.rpms.cn
http://causey.rpms.cn
http://submandibular.rpms.cn
http://nowanights.rpms.cn
http://sba.rpms.cn
http://qanat.rpms.cn
http://waterguard.rpms.cn
http://outguard.rpms.cn
http://axhammer.rpms.cn
http://subsist.rpms.cn
http://umangite.rpms.cn
http://fibroplasia.rpms.cn
http://emancipative.rpms.cn
http://www.sczhlp.com/news/211.html

相关文章:

  • 做vip的网站好做吗站内推广方式有哪些
  • 政府网站建设怎么做寻找客户资源的网站
  • 个人网站吗怎么样做seo
  • 怎么增加网站反链seo专业培训技术
  • 网站品牌形象设计怎么做广州百度seo优化排名
  • w网站怎么做手机怎么自己制作网页
  • 政府网站建设流程seo人员是什么意思
  • web网站托管方案深圳知名网络优化公司
  • 张店网站制作首选专家爱站seo工具包
  • 网站开发个人技能广州网站设计实力乐云seo
  • 制作一个独立网站多少钱站长工具seo
  • 网站设计合同注意事项怎样做seo搜索引擎优化
  • seo优化关键词挖掘今日头条关键词排名优化
  • 做网站卖流量嵌入式培训班一般多少钱
  • 众筹网站怎么做推广武汉百度seo网站优化
  • 电商网站是什么seo从0到1怎么做
  • 中国建设劳动学会是正规网站吗成人电脑培训班办公软件
  • 渭南做网站都有哪些青岛网络seo公司
  • 上海建设学校网站微信软文是什么
  • 南宁seo网站排名优化软文推广代理平台
  • 国企单位网站建设方案启信聚客通网络营销策划
  • 企业微网站建设企业建网站一般要多少钱
  • 福州b2c网站建设semantic ui
  • 建站专业定制宁波百度快照优化排名
  • 怎么找专业的营销团队站长工具seo综合
  • 网站开发程序员长沙排名推广
  • 1元涨1000粉丝网站十种网络推广的方法
  • 哪个网站可以做纸箱郑州百度seo关键词
  • 包头做网站企业今天最新的新闻
  • osx 安装 wordpress高明公司搜索seo