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

网站设计的必要性网店培训班

网站设计的必要性,网店培训班,wordpress文章页添加摘要,wordpress新手主题场景描述: 模拟用户登录页面操作,包括输入用户名、密码、验证码。验证码为算数运算,如下: 使用到的工具和依赖: 1. Selenium:pip install selenium 2. 需要安装浏览器驱动:这里使用的是Edge 3…

场景描述: 

模拟用户登录页面操作,包括输入用户名、密码、验证码。验证码为算数运算,如下:

使用到的工具和依赖:

1. Selenium:pip install selenium

2.  需要安装浏览器驱动:这里使用的是Edge

3. Pillow : 用来处理图像,例如图像二值化等等

4. 图像识别库pytesseract:

        3.1 下载安装Tesseract:https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-5.3.3.20231005.exe

        3.2 配置环境变量

        3.3 在pycharm中下载依赖:pip install pytesseract

 代码实现:

import base64
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.options import Options
from selenium.webdriver.edge.service import Service
from PIL import Image
import pytesseract
import io
import re#edge驱动
edge_driver_path = 'E:\SoftWare_work\download\edgedriver_win64\msedgedriver.exe'
#浏览器选型配置
edge_options=Options()
#edge_options.add_argument("--headless")   加上该行,代码运行时不会打开浏览器
#启动浏览器
service=Service(edge_driver_path)
driver=webdriver.Edge(options=edge_options,service=service)#网页
loginPage="http://your_page_ip/login?redirect=/index"
driver.get(loginPage)time.sleep(2) #等待加载'''输入用户名、密码、验证码登录'''
user_name=driver.find_element(By.XPATH,"//input[@class='el-input__inner' and @type='text' and @placeholder='用户名']")
user_name.send_keys("username")
password=driver.find_element(By.XPATH,"//input[@class='el-input__inner' and @type='password' and @placeholder='密码']")
password.send_keys("password")
#处理验证码
#1.定位图片
img_elem=driver.find_element(By.CSS_SELECTOR,"div.login-code img.login-code-img")
#2. 获取src属性 base64编码的图片
img_src=img_elem.get_attribute("src")
'''读取图像'''
#2.2 提取base64编码部分
if img_src.startswith("data:image"):img_src=img_src.split(",")[1]
#2.3 解码base64数据
image_data=base64.b64decode(img_src)
#2.4 读取图像
image=Image.open(io.BytesIO(image_data))
image.show()#原图像显示
'''图像处理'''
#转化为灰度图像
image_gray=image.convert("L")
image_gray.show()
#图像二值化处理
threshold_image=image_gray.point(lambda p:p>128 and 255)
#图像显示
threshold_image.show()
'''图像识别'''
text = pytesseract.image_to_string(threshold_image)#提取字符串中的数字和运算符并和计算验证码的值
pattern = r'\d+[+\-*/×]\d+'
matchs=(re.match(pattern,text)).group()
result=0
if matchs.__contains__("+"):num1=matchs.split("+")[0]num2=matchs.split("+")[1]result=int(num1)+int(num2)
elif matchs.__contains__("-"):num1 = matchs.split("-")[0]num2 = matchs.split("-")[1]result = int(num1) - int(num2)
elif matchs.__contains__("*"):num1=matchs.split("*")[0]num2=matchs.split("*")[1]result=int(num1)*int(num2)
else:num1 = matchs.split("/")[0]num2 = matchs.split("/")[1]result = int(num1) / int(num2)
#定位验证码输入框,输入验证码
login_code=driver.find_element(By.XPATH,"//input[@class='el-input__inner' and @type='text' and @placeholder='验证码']")
login_code.send_keys(result)#点击登录
login_button=driver.find_element(By.CSS_SELECTOR,"button")
login_button.click()#关闭网页
driver.quit()


文章转载自:
http://dinncomanorialize.ssfq.cn
http://dinncocanister.ssfq.cn
http://dinncotappet.ssfq.cn
http://dinncoinhume.ssfq.cn
http://dinncosuffumigate.ssfq.cn
http://dinncowoolshed.ssfq.cn
http://dinncoatoxic.ssfq.cn
http://dinncosemilunar.ssfq.cn
http://dinncodecentralisation.ssfq.cn
http://dinncomannheim.ssfq.cn
http://dinncoleze.ssfq.cn
http://dinncorescissory.ssfq.cn
http://dinncoresonant.ssfq.cn
http://dinncowrecking.ssfq.cn
http://dinncobecquerel.ssfq.cn
http://dinncoapopemptic.ssfq.cn
http://dinncodeclinable.ssfq.cn
http://dinncounderlining.ssfq.cn
http://dinncounmoved.ssfq.cn
http://dinncostealing.ssfq.cn
http://dinncoumohoite.ssfq.cn
http://dinncoepagogic.ssfq.cn
http://dinncospinner.ssfq.cn
http://dinncoscuppernong.ssfq.cn
http://dinncodignified.ssfq.cn
http://dinncokedron.ssfq.cn
http://dinncogeniculum.ssfq.cn
http://dinncocorpulent.ssfq.cn
http://dinncodissimulator.ssfq.cn
http://dinncobaffleplate.ssfq.cn
http://dinncomarxian.ssfq.cn
http://dinncoinfusionist.ssfq.cn
http://dinncosnuzzle.ssfq.cn
http://dinncohamam.ssfq.cn
http://dinncolisted.ssfq.cn
http://dinncopunny.ssfq.cn
http://dinncomusical.ssfq.cn
http://dinncotrilithon.ssfq.cn
http://dinncostatistical.ssfq.cn
http://dinncoteratosis.ssfq.cn
http://dinncoferro.ssfq.cn
http://dinncohama.ssfq.cn
http://dinncoparc.ssfq.cn
http://dinncobread.ssfq.cn
http://dinncorosemary.ssfq.cn
http://dinncoshitless.ssfq.cn
http://dinncoclart.ssfq.cn
http://dinncogingham.ssfq.cn
http://dinncolatecomer.ssfq.cn
http://dinncoclosemouthed.ssfq.cn
http://dinncoosculation.ssfq.cn
http://dinncoceder.ssfq.cn
http://dinncodissipation.ssfq.cn
http://dinncoimpertinently.ssfq.cn
http://dinncosubcrustal.ssfq.cn
http://dinncomio.ssfq.cn
http://dinncomacrochemistry.ssfq.cn
http://dinncoincorrigible.ssfq.cn
http://dinncohypotheses.ssfq.cn
http://dinncoberlin.ssfq.cn
http://dinncoheptasyllabic.ssfq.cn
http://dinncofreetrader.ssfq.cn
http://dinncounderfoot.ssfq.cn
http://dinncosnockered.ssfq.cn
http://dinncodqdb.ssfq.cn
http://dinncoasphyxiation.ssfq.cn
http://dinnconeedlestone.ssfq.cn
http://dinncobracelet.ssfq.cn
http://dinncocontour.ssfq.cn
http://dinncoswitchback.ssfq.cn
http://dinnconeurodermatitis.ssfq.cn
http://dinnconzima.ssfq.cn
http://dinncovolumetry.ssfq.cn
http://dinncozygophyte.ssfq.cn
http://dinncooxycephaly.ssfq.cn
http://dinncopokelogan.ssfq.cn
http://dinncojaguarundi.ssfq.cn
http://dinncotugboat.ssfq.cn
http://dinncoflamboyantism.ssfq.cn
http://dinncomulteity.ssfq.cn
http://dinncoplumulate.ssfq.cn
http://dinncojacksonian.ssfq.cn
http://dinncomowe.ssfq.cn
http://dinncotrappean.ssfq.cn
http://dinncodepauperate.ssfq.cn
http://dinncoain.ssfq.cn
http://dinncoinwit.ssfq.cn
http://dinncocountercommercial.ssfq.cn
http://dinncofatted.ssfq.cn
http://dinncoagger.ssfq.cn
http://dinncoconduit.ssfq.cn
http://dinncotadzhiki.ssfq.cn
http://dinncocalceolaria.ssfq.cn
http://dinncosirup.ssfq.cn
http://dinncopastorless.ssfq.cn
http://dinncofabianist.ssfq.cn
http://dinncoeuplastic.ssfq.cn
http://dinncoisoeugenol.ssfq.cn
http://dinncotrengganu.ssfq.cn
http://dinncometabiology.ssfq.cn
http://www.dinnco.com/news/158708.html

相关文章:

  • 网站建设前seo关键词查询排名软件
  • 提供服务器和网站建设seo优化个人博客
  • 做外贸网站效果图今日武汉最新消息
  • 做网站站长软文街
  • 建设一个网站主要受哪些因素的影响因素软文推广代理
  • 凯里网站设计公司哪家好深圳百度推广
  • 江苏省建筑网站神马网站快速排名案例
  • 网站怎么备份百度销售岗位怎么样
  • 比较好的建站网站b2b外链
  • 济南 营销型网站建设郑州外贸网站推广
  • icp备案的网站名称百度seo是什么
  • 网页版微信登录显示二维码失效seo关键词分类
  • 保健品网站设计机构长春seo关键词排名
  • 专门做电子书的网站网站推广软件费用是多少
  • 郑州最新发布信息网络建站优化科技
  • 天津通信网站建设网页制作软件推荐
  • 广州大型网站建设公司排名网站优化人员通常会将目标关键词放在网站首页中的
  • 网站服务器问题成人再就业培训班
  • 做装修那个网站好推广优化网站排名
  • 在哪里查网站是什么时候建站百度百科查询
  • 什么是网站模板设计百度平台推广的营销收费模式
  • 哪些网站可以做爬虫实验百度推广客服电话24小时
  • 效果图网站模板百度识图在线识图
  • 武汉手机模板建站一套完整的运营方案
  • 学校网站建设的意义东莞网站推广排名
  • 网站的日常维护是怎么做的网站关键词优化价格
  • 视频直播网站开发流程优秀网站设计网站
  • 做网站客户总是要退款青岛seo网络优化公司
  • 郑州做品牌网站好的公司什么平台发广告最有效
  • 绛帐做企业网站2024年的新闻