【python】用selenium右键保存图片报错 AttributeError: module ‘pyscreeze‘ has no attribute ‘locateOnWindow‘的解决方法

使用selenium爬取图片时,通过模拟鼠标右键保存图片出现AttributeError,原因是最新版pyscreeze缺少'locateOnWindow'属性。解决方法是回退到pyscreeze 0.9.50版本,这样就能正常执行保存图片的操作。
摘要由CSDN通过智能技术生成

在使用selenium模块进行爬取图片时,模拟鼠标右键点击,选择“图片另存为”保存图片(不使用pyautogui模块)

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from time import sleep

url = 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcdn.duitang.com%2Fuploads%2Fitem%2F201202%2F18%2F20120218194349_ZHW5V.thumb.700_0.jpg&refer=http%3A%2F%2Fcdn.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1633348528&t=794e58b55dfe37e5f3082568feb89783'

driver = webdriver.Chrome()
driver.get(url)
element = driver
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值