图片保存的一种思路
import pyautogui
# 模拟鼠标右键图片另存为
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
webdriver = webdriver.Chrome()
webdriver.get("https://www.baidu.com")
# 找到图片
img = webdriver.find_element(By.XPATH,'//*[@id="s_lg_img"]')
# 模拟鼠标右键
action = ActionChains(webdriver)
action.move_to_element(img)
# 右键点击
action.context_click(img).key_down(Keys.SHIFT).key_down(Keys.ALT).perform()
# action.perform()
#
# # 模拟鼠标右键图片另存为
pyautogui.typewrite(['down','down','down','down','down','down','down','down','enter'])
#
time.sleep(5)
pyautogui.typewrite(['enter'])
#
time.sleep(5)
webdriver.quit()
0则评论给“模拟网页鼠标右键点击”