【问题标题】:Python, selenium, Chrome and ActionChains to save a webpagePython、selenium、Chrome 和 ActionChains 来保存网页
【发布时间】:2016-11-05 07:11:32
【问题描述】:

我正在尝试使用 Python、Chrome 和 ActionChains 来保存网页。

代码似乎在一台计算机上运行良好,但在另一台计算机上却不行。

我检查了代码,也尝试了selenium action chains no effect 给出的建议,但还是不行。

哪里出错了?谢谢。

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import win32com.client as comclt

chromedriver = "c:\Python27\\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = chromedriver

driver = webdriver.Chrome(chromedriver)
driver.maximize_window()

aaa = driver.get("https://sg.yahoo.com/?p=us")
time.sleep(3)

save_me = ActionChains(driver).key_down(Keys.CONTROL).key_down('s').key_up(Keys.CONTROL).key_up('s')
save_me.perform()
time.sleep(2)
wsh= comclt.Dispatch("WScript.Shell")
wsh.AppActivate("chrome")
time.sleep(1)
wsh.SendKeys("{ENTER}")

driver.quit()

【问题讨论】:

    标签: python selenium-chromedriver


    【解决方案1】:

    Chrome 和 Chromedriver(32 位、64 位)的版本似乎很重要。尝试了另一个版本,它可能工作正常。

    【讨论】:

      猜你喜欢
      • 2012-06-13
      • 2018-12-28
      • 1970-01-01
      • 2020-03-18
      • 2013-09-01
      • 2016-10-16
      • 1970-01-01
      • 2021-07-13
      • 2020-08-31
      相关资源
      最近更新 更多