我试图使用 selenium 从 google chrome 下载文件。我下面使用的代码运行良好。但不知怎的,它不再起作用了。有任何想法吗?
import os.path
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import Select
RAWDATA_URL = 'https://oui.doleta.gov/unemploy/DataDownloads.asp'
options = webdriver.ChromeOptions()
prefs = {'download.default_directory' : SAVE_PATH, "download.prompt_for_download": False}
options.add_experimental_option('prefs', prefs)
driver = webdriver.Chrome(executable_path = DRIVE_PATH, chrome_options = options)
driver.get(RAWDATA_URL)
time.sleep(5)
Run Code Online (Sandbox Code Playgroud)
driver.find_element_by_xpath("//*[@id='main']/table[38]/tbody/tr[2]/td[5]/a").click()
Run Code Online (Sandbox Code Playgroud)
driver.get("https://oui.doleta.gov/unemploy/csv/ar9047.csv")
Run Code Online (Sandbox Code Playgroud)
我预计 csv 文件可以成功下载。但谷歌浏览器只是告诉我“失败-下载错误”。
import datetime
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from …Run Code Online (Sandbox Code Playgroud)