如何在python中使用硒下载pdf文件 [英] How to download pdf files using selenium in python

查看:79
本文介绍了如何在python中使用硒下载pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用硒从网站下载pdf文件,但我能够打开文件,但无法使用代码自动下载.

I am trying to download pdf files from website using selenium but i am able to open file but its not auto downloadable using code.

代码:

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)

请提出建议.预先谢谢你

Please suggest. Thank you in advance

推荐答案

以上问题已解决

    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)

这篇关于如何在python中使用硒下载pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆