我正在尝试使用selenium从网站下载pdf文件,但我能够打开文件,但无法使用代码自动下载。
码:
chrome_profile = webdriver.ChromeOptions() profile = {"download.default_directory": "C:\Users\Downloads", "download.prompt_for_download": False, "download.directory_upgrade": True, "plugins.plugins_disabled": ["Chrome PDF Viewer"]} chrome_profile.add_experimental_option("prefs", profile)
请提出建议。先感谢您
以上问题现已解决
prefs = {"plugins.always_open_pdf_externally": True} chromeOptions.add_experimental_option("prefs",prefs) chromedriver = "\path\chromedriver.exe" driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)