我用selenium开始下载.下载完成后,需要采取某些措施,是否有任何简单的方法可以找出下载完成的时间?(我正在使用FireFox驱动程序)
我正在尝试创建一个脚本,通过 Chrome 的打印功能自动保存只读 pdf,以将其另存为同一文件夹中的另一个 pdf。这将删除“只读”功能。但是,在运行脚本时,我不确定在哪里可以指定我自己的特定目标文件夹,脚本将其直接保存在下载文件夹中。
以下代码的完整道具/sf/users/100283011/。
任何帮助将不胜感激。
import json
from selenium import webdriver
downloadPath = r'mypath\downloadPdf\\'
appState = {
"recentDestinations": [
{
"id": "Save as PDF",
"origin": "local"
}
],
"selectedDestinationId": "Save as PDF",
"version": 2
}
profile = {'printing.print_preview_sticky_settings.appState':json.dumps(appState)}
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option('prefs', profile)
chrome_options.add_argument('--kiosk-printing')
driver = webdriver.Chrome(chrome_options=chrome_options)
pdfPath = r'mypath\protected.pdf'
driver.get(pdfPath)
driver.execute_script('window.print();')
Run Code Online (Sandbox Code Playgroud)