首页 > 其他分享 >selenium截取元素,并保存图片到本地

selenium截取元素,并保存图片到本地

时间:2023-03-07 11:22:17浏览次数:30  
标签:xpath body 截取 selenium html 本地 div cw

# xpath截取元素,并保存到本地 canvasEle1=driver.find_element_by_xpath('/html/body/div[2]/div/div[1]/canvas[1]') canvasEle2=driver.find_element_by_xpath('/html/body/div[2]/div/div[1]/canvas[2]') canvasEle3=driver.find_element_by_xpath('/html/body/div[2]/div/div[1]/canvas[3]') canvas1=canvasEle1.screenshot_as_png  # 截取后直接是二进制 canvas2=canvasEle2.screenshot_as_png canvas3=canvasEle3.screenshot_as_png with open(r"C:\Users\Administrator\Desktop\工作\code\a_cw_web\cw_version7\test_photo\img\1.jpg", mode="wb")as f:     f.write(canvas1) with open(r"C:\Users\Administrator\Desktop\工作\code\a_cw_web\cw_version7\test_photo\img\2.jpg", mode="wb")as f:     f.write(canvas2) with open(r"C:\Users\Administrator\Desktop\工作\code\a_cw_web\cw_version7\test_photo\img\3.jpg", mode="wb")as f:     f.write(canvas3)   参考: https://www.cnblogs.com/lihongtaoya/p/16759942.html

标签:xpath,body,截取,selenium,html,本地,div,cw
From: https://www.cnblogs.com/hyd666kkk/p/17187414.html

相关文章

  • Caffeine高性能本地缓存框架初探
    通常情况下,为了提升服务性能,使用缓存框架是一个非常常见的选择。在Java语境下,经过我查阅,Caffeine被称作地标最强Java本地缓存框架。Caffeine是站在巨人(GuavaCache)的肩膀上,......
  • selenium无头浏览器
    fromselenium.webdriverimportEdge#在这里导入浏览器设置相关的类fromselenium.webdriver.edge.optionsimportOptions#无可视化界面设置#edge_options=Op......
  • python_selenium(部分笔记)
    什么是自动化?自动化就是以人力驱动的测试行为转化为机械执行的一种过程目的:节省人力,时间或者硬件资源,提高测试效率哪些场景下适合做自动化?1,任务测试明确,不会频繁变动2,每日......
  • Selenium CHANGELOG[最新版本4.8.2 计划中]
    SeleniumCHANGELOG[持续更新]源文件https://github.com/SeleniumHQ/selenium/blob/trunk/py/CHANGES搬运工对重点版本做时间标注,具体时间点可以参考https://github.c......
  • selenium窗口之间的切换
    importtimefromselenium.webdriverimportEdgefromselenium.webdriver.common.byimportByfromselenium.webdriver.common.keysimportKeys#键盘输入#1.......
  • 10,docker基础之---Harbor+阿里云+本地镜像仓库
    什么是镜像仓库?存放着很多镜像的仓库。为什么要使用镜像仓库?例如我们之前使用的pull下载mysql镜像的时候下载的镜像就是存放在他人的镜像仓库之上,公司内部部署镜像仓库即可......
  • 安卓NDK本地开发中使用logcat打印日志
    配置在需要打印日志的文件中添加以下头文件和宏定义#include<android/log.h>#defineLOGD(...)__android_log_print(ANDROID_LOG_INFO,"LOG_TAG",__VA_ARGS__)#de......
  • ABP使用SQLite本地数据库
    1、修改EFCore中的依赖,添加Sqlite的依赖,移除原先的sqlserver的依赖  2、修改配置中的使用  3、修改Web.Host中的配置文件中appsettings.json中数据库的地址 ......
  • selenium+Autolt上传图片(非input属性)
    原理说明:autoit它设计用于WindowsGUI(图形用户界面)中进行自动化操作的一个程序,使用前需要安装,一般网站中图片上传会涉及到点击上传图片按钮就会弹出一个Windows的框用于......
  • git拉取远程分支到本地
    1.新建一个文件夹2.初始化gitinit3.本地仓库和远程仓库建立连接[email protected]:fireworkwing/saveFileService.git4.拉取所有分支到本地仓库......