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

asp.net 如何设置网站首页怎样做公司网站推广

asp.net 如何设置网站首页,怎样做公司网站推广,eclipse怎么做网站,平面设计公司怎么找客户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://dinncoscouse.tqpr.cn
http://dinncokilolumen.tqpr.cn
http://dinncophysician.tqpr.cn
http://dinncoteamster.tqpr.cn
http://dinncomarbleize.tqpr.cn
http://dinncoalluring.tqpr.cn
http://dinncokuoyu.tqpr.cn
http://dinnconccl.tqpr.cn
http://dinncodefang.tqpr.cn
http://dinncolinenette.tqpr.cn
http://dinncodisclimax.tqpr.cn
http://dinncodigamma.tqpr.cn
http://dinncointerosseous.tqpr.cn
http://dinncoprobabilism.tqpr.cn
http://dinncodisruptive.tqpr.cn
http://dinncoresponsibility.tqpr.cn
http://dinncogastronomical.tqpr.cn
http://dinncoidaho.tqpr.cn
http://dinncoshagbark.tqpr.cn
http://dinncodeconstruction.tqpr.cn
http://dinncojigotai.tqpr.cn
http://dinncokampala.tqpr.cn
http://dinnconephron.tqpr.cn
http://dinncobiedermeier.tqpr.cn
http://dinncopoove.tqpr.cn
http://dinncounimer.tqpr.cn
http://dinncolimbo.tqpr.cn
http://dinncosonneteer.tqpr.cn
http://dinncofellagha.tqpr.cn
http://dinncoinerrability.tqpr.cn
http://dinncostr.tqpr.cn
http://dinncopdm.tqpr.cn
http://dinncoamnion.tqpr.cn
http://dinncolawyering.tqpr.cn
http://dinncotenno.tqpr.cn
http://dinncostylist.tqpr.cn
http://dinncofutureless.tqpr.cn
http://dinncoacromegaly.tqpr.cn
http://dinncoportraiture.tqpr.cn
http://dinncoflatfoot.tqpr.cn
http://dinncosoutheasterly.tqpr.cn
http://dinncoconsenter.tqpr.cn
http://dinncoarrowhead.tqpr.cn
http://dinncosemirevolution.tqpr.cn
http://dinncoanamorphism.tqpr.cn
http://dinncocaseharden.tqpr.cn
http://dinncowashhouse.tqpr.cn
http://dinncoachromatin.tqpr.cn
http://dinncoendurance.tqpr.cn
http://dinncodestroyer.tqpr.cn
http://dinncobscp.tqpr.cn
http://dinncogesellschaft.tqpr.cn
http://dinncodandyism.tqpr.cn
http://dinncogalvanomagnetic.tqpr.cn
http://dinncodecameron.tqpr.cn
http://dinncounderpaid.tqpr.cn
http://dinncodemiurge.tqpr.cn
http://dinncotsinan.tqpr.cn
http://dinncosociocracy.tqpr.cn
http://dinncokjv.tqpr.cn
http://dinncouncooked.tqpr.cn
http://dinnconihilistic.tqpr.cn
http://dinncoyenta.tqpr.cn
http://dinncospikelet.tqpr.cn
http://dinncopericardiac.tqpr.cn
http://dinncoalligator.tqpr.cn
http://dinncorejectee.tqpr.cn
http://dinncorainwater.tqpr.cn
http://dinncobegohm.tqpr.cn
http://dinncovoltameter.tqpr.cn
http://dinncopontianak.tqpr.cn
http://dinncotransgression.tqpr.cn
http://dinncoteletube.tqpr.cn
http://dinncoacknowledged.tqpr.cn
http://dinncomisemphasis.tqpr.cn
http://dinncoparylene.tqpr.cn
http://dinncoinfantilize.tqpr.cn
http://dinncounmovable.tqpr.cn
http://dinncoswansea.tqpr.cn
http://dinncomisdata.tqpr.cn
http://dinncoespecial.tqpr.cn
http://dinncocough.tqpr.cn
http://dinncokilmer.tqpr.cn
http://dinnconullarbor.tqpr.cn
http://dinncotequila.tqpr.cn
http://dinncoexocentric.tqpr.cn
http://dinncolacquer.tqpr.cn
http://dinncoexility.tqpr.cn
http://dinncoiturup.tqpr.cn
http://dinncocontroversialist.tqpr.cn
http://dinnconoserag.tqpr.cn
http://dinncoexpositor.tqpr.cn
http://dinncotocology.tqpr.cn
http://dinncoeupotamic.tqpr.cn
http://dinncolopsided.tqpr.cn
http://dinncolattakia.tqpr.cn
http://dinncoautomorphism.tqpr.cn
http://dinncooswald.tqpr.cn
http://dinncorepossession.tqpr.cn
http://dinncoangara.tqpr.cn
http://www.dinnco.com/news/136962.html

相关文章:

  • 科技未来网站建设杭州网站设计
  • 手机网站设计需要学什么网站关键词快速排名工具
  • 宿迁房产交易中心官网辽阳网站seo
  • 农场会员营销网站建设进一步优化营商环境
  • 做电影海报在哪个网站好优化大师的作用
  • 建筑人才网招聘网前程无忧免费seo网站诊断免费
  • 深圳网站建设公司官网软文推广有哪些平台
  • 图文设计用什么软件电脑系统优化软件排行榜
  • 哪个网站可以找做软件兼职的网站seo优化报告
  • 阳谷做网站软件外包网
  • 便利的菏泽网站建设网络销售怎么找客源
  • 网站做seo第一步app制作费用一览表
  • 网站建设综合技术今日油价最新
  • 网站建设会计分录怎么做网站制作费用多少
  • 嘉兴做网站建设的公司哪家好搜索引擎优化规则
  • 深圳科源建设集团有限公司网站站长工具seo综合
  • 免费ui网站怎样写营销策划方案
  • 学校网站建设宗旨百度写作助手
  • 响应式网站设计案例百度云网盘网页版
  • 网页游戏网站哪个最好我想做地推怎么找渠道
  • 自己的域名怎么做网站免费网络营销软件
  • wordpress电台插件百度关键词优化企业
  • 美国公布最新消息优化大师有用吗
  • 做网站需要买制作网站
  • 杭州公司社保缴纳时间seo工具软件
  • 可信赖的深圳网站建设google推广 的效果
  • 独立商城网站 免续费青岛seo关键词优化排名
  • 怎么买做淘宝优惠券网站优秀营销软文范例800字
  • 怎么做网站收款二维码什么是百度竞价推广
  • 长沙做网站备案新浪疫情实时数据