【问题标题】:selenium doesn't download pdf automatically (chrome driver and python)selenium 不会自动下载 pdf(chrome 驱动程序和 python)
【发布时间】:2022-06-22 21:51:48
【问题描述】:

我想从这个链接下载 pdf 文件:https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9152778

按照指令Selenium Webdriver: How to Download a PDF File with Python? 我创建了这样的代码:

url = 'https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9152778'
options = Options()
options.headless = False
options.add_experimental_option('prefs',  {
      "download.default_directory": outdir,
      "download.prompt_for_download": False,
      "download.directory_upgrade": True,
      "plugins.always_open_pdf_externally": True,
      }
  )
chromedriver = driver_path
driver = webdriver.Chrome(chromedriver, options=options)
driver.get(url)

selenium 可以成功打开浏览器。但是它不会下载pdf,而是显示如下页面:

我必须点击打开按钮才能开始下载。 html 也不显示有关按钮的任何信息。

谁能告诉我如何修改代码以从该站点下载 pdf 文件?当从其他站点给出 pdf url 时,脚本没有问题!提前致谢!

【问题讨论】:

    标签: selenium selenium-chromedriver web-crawler


    【解决方案1】:

    去掉这行的逗号

    "plugins.always_open_pdf_externally": True,
    

    改为:

    "plugins.always_open_pdf_externally": True
    

    【讨论】:

      【解决方案2】:

      你解决了吗? 我也有同样的问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-11-21
        • 1970-01-01
        • 1970-01-01
        • 2020-02-04
        • 2015-05-21
        • 2018-05-23
        • 1970-01-01
        相关资源
        最近更新 更多