【发布时间】:2019-04-25 16:14:06
【问题描述】:
我正在尝试用鼠标右键单击并单击在 selenium python 中另存为图像。 我可以使用以下方法执行右键单击,但是执行右键单击的下一个操作不再起作用。我该如何解决这个问题?
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
driver.get(url)
# get the image source
img = driver.find_element_by_xpath('//img')
actionChains = ActionChains(driver)
actionChains.context_click(img).send_keys(Keys.ARROW_DOWN).send_keys(Keys.ARROW_DOWN).send_keys(Keys.RETURN).perform()
【问题讨论】:
-
是否要求您必须右键单击/另存为,或者您只是试图通过任何必要的方式获取图像内容?
-
@cody 我需要右键单击 /save as 或使用 selenium 浏览器在下载图像时使用的相同会话和 cookie,而不仅仅是简单的 urlretrieve 功能。
标签: python selenium web-crawler