我目前正在python中创建一个selenium脚本.我需要使用send_keys函数在文本框中输入内容.到目前为止,它正在这样做.但是,对于观察我需要减慢send_keys填充文本字段的速度.有没有办法可以做到这一点?另外,selenium中有send_keys的替代品吗?谢谢和问候karan
我想使用 selenium 和 python 下载 .mhtml 格式的网页。我正在使用以下代码:
driver = webdriver.Chrome()
driver.get("http://www.yahoo.com")
with open("/path/to/page_source.mhtml", "w", encoding="utf-8") as f:
f.write(driver.page_source)
Run Code Online (Sandbox Code Playgroud)
它保存了页面,但页面只有源代码。无法查看页面原始内容。有什么建议么?
谢谢卡兰
我想使用硒和python下载网页。使用以下代码:
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument('--save-page-as-mhtml')
d = DesiredCapabilities.CHROME
driver = webdriver.Chrome()
driver.get("http://www.yahoo.com")
saveas = ActionChains(driver).key_down(Keys.CONTROL)\
.key_down('s').key_up(Keys.CONTROL).key_up('s')
saveas.perform()
print("done")
Run Code Online (Sandbox Code Playgroud)
但是上述代码无法正常工作。我正在使用Windows7。是否可以打开“另存为”对话框?
谢谢卡兰