在使用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