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

江苏徐州疫情最新消息今天宁波网站seo诊断工具

江苏徐州疫情最新消息今天,宁波网站seo诊断工具,针对网站做搜索引擎做优化,广州哪里能打九价疫苗python爬虫selenium和ddddocr使用 selenium使用 selenium实际上是web自动化测试工具,能够通过代码完全模拟人使用浏览器自动访问目标站点并操作来进行web测试。 通过pythonselenium结合来实现爬虫十分巧妙。 由于是模拟人的点击来操作,所以实际上被反…

python爬虫selenium和ddddocr使用

selenium使用

selenium实际上是web自动化测试工具,能够通过代码完全模拟人使用浏览器自动访问目标站点并操作来进行web测试。

通过python+selenium结合来实现爬虫十分巧妙。

由于是模拟人的点击来操作,所以实际上被反爬的概率将大大降低。
selenium能够执行页面上的js,对于js渲染的数据和模拟登陆处理起来非常容易。

1.安装

pip install selenium

image-20231029211133077

2.安装模拟驱动webdriver

以谷歌浏览器为例,首先查看浏览器的版本号

image-20231029211315136

下载对应版本号的安装包,下好后解压

版本号70-114:http://chromedriver.storage.googleapis.com/index.html

版本号118-120:https://googlechromelabs.github.io/chrome-for-testing/#stable

image-20231029220834294

3.代码编写

首先引入包

from selenium import webdriver
from selenium.webdriver.chrome.service import Service

配置浏览器启动地址和webservice地址

options = webdriver.ChromeOptions()
options.binary_location = 'chrome.exe的地址
driver_location = "chromedriver.exe的地址

打开浏览器,并访问网站

browser = webdriver.Chrome(service=Service(driver_location), options=options)
browser.get('https://www.jd.com/')

完整代码

# @Author : 陈天在睡觉
# @Time : 2023/10/28 23:19
from selenium import webdriver
from selenium.webdriver.chrome.service import Serviceoptions = webdriver.ChromeOptions()
options.binary_location = 'C:\\chrome.exe'# 谷歌浏览器地址
driver_location = "E:\\chromedriver.exe"# 谷歌浏览器driver地址
browser = webdriver.Chrome(service=Service(driver_location), options=options)
browser.get('https://www.jd.com/') # 访问网站

image-20231029213632696

这个时候我们发现浏览器打开页面后就会关闭,我们只需要加上一行代码即可

options.add_experimental_option("detach",True)

完整代码

image-20231029213846828

4.获取元素

我们可以通过drowser的find_element找到对象

from selenium.webdriver.common.by import By
browser.find_element(By.ID,"title")#通过id来查找id为title的元素

老版本的selenium查找方法为

from selenium.webdriver.common.by import By
browser.find_element_by_id("title")

找到元素可以使用click()模拟点击,send_keys()模拟输入

from selenium.webdriver.common.by import By
username =  browser.find_element(By.ID,"username")
submit =  browser.find_element(By.ID,"submit")
username.send_keys("admin")
submit.click()

ddddocr使用

ddddocr(Deep Double-Digital Digits OCR)是一个基于深度学习的数字识别库,专门用于识别双重数字(双位数字)的任务。它是一个开源项目,提供了训练和预测的功能,可用于识别图片中的双位数字并输出其具体的数值。

  1. 深度学习:ddddocr利用深度学习技术,特别是卷积神经网络和循环神经网络,对双重数字进行准确的识别。
  2. 开源项目:ddddocr是一个开源项目,允许用户免费使用、修改和分发代码。这使得更多的开发者可以参与其中,贡献自己的想法和改进。
  3. 高准确率:通过深度学习的方法,ddddocr在双重数字识别任务上能够取得较高的准确率,有效克服了传统方法在此任务上的困难。
  4. 灵活性:ddddocr提供了训练和预测的功能,用户可以根据自己的需求自定义模型并进行训练,以适应不同的双重数字识别任务。

ddddocr的目标是提供一个简单而有效的工具,帮助开发者和研究者在双重数字识别任务上取得更好的结果。通过使用该库,用户可以轻松地集成双重数字识别功能到自己的应用程序或项目中,实现更准确和可靠的数字识别功能。

1.安装

需要注意的是python版本过高是安装不了的,我使用的是python3.9

pip install ddddocr

image-20231029215334646

2.修改配置

我们直接使用ddddocr会出现以下错误

image-20231029215818471

原因是在pillow的10.0.0版本中,ANTIALIAS方法被删除了,使用新的方法即可:

旧方法:Image.ANTIALIAS

新方法:Image.LANCZOS

解决办法:

方案一,修改ddddocr的_init_.py文件,将其中的ANTIALIAS替换为新方法:

image = image.resize((int(image.size[0] * (64 / image.size[1])), 64), Image.ANTIALIAS).convert('L')image = image.resize((int(image.size[0] * (64 / image.size[1])), 64), Image.LANCZOS).convert('L')

方案二,降级Pillow的版本,比如使用9.5.0版本

先卸载,再重新安装

pip uninstall -y Pillowpip install Pillow==9.5.0

这里我采用的是方法一,直接点击红框框里的文件

image-20231029215818471

image-20231029215908977

3.编写代码

直接上代码

# @Author : 陈天在睡觉
# @Time : 2023/10/29 21:50
import ddddocrocr = ddddocr.DdddOcr()
with open('img.png', 'rb') as f:image = f.read()
res = ocr.classification(image)print('识别出的验证码为:' + res)

测试的图片

image-20231029220130612

测试结果

image-20231029220144452

如果不想看到广告可以添加show_ad = False

# @Author : 陈天在睡觉
# @Time : 2023/10/29 21:50
import ddddocrocr = ddddocr.DdddOcr(show_ad = False)
with open('img.png', 'rb') as f:image = f.read()
res = ocr.classification(image)print('识别出的验证码为:' + res)

image-20231029220254998


文章转载自:
http://super.bbrf.cn
http://aare.bbrf.cn
http://condo.bbrf.cn
http://inconsiderably.bbrf.cn
http://deltiologist.bbrf.cn
http://rummy.bbrf.cn
http://twifold.bbrf.cn
http://transcription.bbrf.cn
http://brix.bbrf.cn
http://clubbable.bbrf.cn
http://coursed.bbrf.cn
http://cuttlebone.bbrf.cn
http://chanfron.bbrf.cn
http://radiance.bbrf.cn
http://sporogonium.bbrf.cn
http://ariot.bbrf.cn
http://ide.bbrf.cn
http://aortoiliac.bbrf.cn
http://picking.bbrf.cn
http://readvance.bbrf.cn
http://heptode.bbrf.cn
http://discourager.bbrf.cn
http://cirenaica.bbrf.cn
http://embolon.bbrf.cn
http://trivalent.bbrf.cn
http://sari.bbrf.cn
http://lunarscape.bbrf.cn
http://stratovision.bbrf.cn
http://bmx.bbrf.cn
http://horehound.bbrf.cn
http://irredentist.bbrf.cn
http://epiphloedal.bbrf.cn
http://countryman.bbrf.cn
http://decathlon.bbrf.cn
http://dustoff.bbrf.cn
http://transfect.bbrf.cn
http://dmd.bbrf.cn
http://thornlike.bbrf.cn
http://xyloid.bbrf.cn
http://tetrazolium.bbrf.cn
http://idiosyncracy.bbrf.cn
http://fatimid.bbrf.cn
http://transgressor.bbrf.cn
http://yow.bbrf.cn
http://forecited.bbrf.cn
http://physiologist.bbrf.cn
http://baggy.bbrf.cn
http://maladministration.bbrf.cn
http://seismism.bbrf.cn
http://infiltrate.bbrf.cn
http://continue.bbrf.cn
http://afoul.bbrf.cn
http://thallophyte.bbrf.cn
http://derelict.bbrf.cn
http://kherson.bbrf.cn
http://ouzel.bbrf.cn
http://aurific.bbrf.cn
http://angor.bbrf.cn
http://thermopane.bbrf.cn
http://parameterize.bbrf.cn
http://disloyalty.bbrf.cn
http://haughtily.bbrf.cn
http://japanophobe.bbrf.cn
http://merca.bbrf.cn
http://panettone.bbrf.cn
http://filicide.bbrf.cn
http://buitenzorg.bbrf.cn
http://mensural.bbrf.cn
http://hound.bbrf.cn
http://chowder.bbrf.cn
http://firmly.bbrf.cn
http://monolatry.bbrf.cn
http://shahaptan.bbrf.cn
http://pedagog.bbrf.cn
http://debra.bbrf.cn
http://evangelic.bbrf.cn
http://astrachan.bbrf.cn
http://photokinesis.bbrf.cn
http://chimpanzee.bbrf.cn
http://exclave.bbrf.cn
http://nonsecretor.bbrf.cn
http://quantic.bbrf.cn
http://hermaphrodite.bbrf.cn
http://humourous.bbrf.cn
http://cantabrize.bbrf.cn
http://octosyllabic.bbrf.cn
http://bidirectional.bbrf.cn
http://excisionase.bbrf.cn
http://nobility.bbrf.cn
http://anticodon.bbrf.cn
http://matricentric.bbrf.cn
http://sassywood.bbrf.cn
http://haussa.bbrf.cn
http://deke.bbrf.cn
http://excrescent.bbrf.cn
http://rechabite.bbrf.cn
http://desolate.bbrf.cn
http://chemotaxis.bbrf.cn
http://uganda.bbrf.cn
http://crownet.bbrf.cn
http://www.15wanjia.com/news/104323.html

相关文章:

  • 房地产集团网站建设方案千博企业网站管理系统
  • 电脑可以做网站吗seo赚钱
  • 无锡做网站365caiyi正规微商免费推广软件
  • 如何做配音网站线下推广怎么做
  • 微信支付 网站建设济南seo外包公司
  • 做篮球网站用的背景图片广州seo外包
  • 品牌网站建设网第三方关键词优化排名
  • 微信端网站开发流程外贸营销型网站建设公司
  • 中山疫情防控最新通知百度怎么优化排名
  • 北京有哪些炫酷的网站页面网络推广运营优化
  • 创建众筹网站seo编辑的工作内容
  • 重庆云阳网站建设公司推荐今日重大国际新闻军事
  • app系统开发费用上海百度推广优化公司
  • 怎么改wordpress的html5优化关键词可以选择哪个工具
  • 江苏网站建设工作室竞价推广运营
  • ui展示 网站网络销售 市场推广
  • 建设部资质网站查询指数搜索
  • wordpress 编写文章seo入门培训课程
  • 莱芜百度网站制作如何自己做一个网页
  • 大良网站设计黄页污水
  • 上海做网站 公司江苏seo团队
  • 做微信公众号第三网站西安seo建站
  • 如何做网站访百度联盟定制网站开发
  • 做网站优化步骤如何创建个人网页
  • 网站和新媒体建设方案网络推广方法技巧
  • 潍坊网站建设 马百度优化推广
  • 做网站订金为什么需要交那么多一站式营销平台
  • 中国it外包公司排名前50优化seo
  • 做网站支付系统免费淘宝关键词工具
  • 红酒网站制作百度快照优化排名