【问题标题】:how to download with splinter knowing direction and name of the file如何在知道文件的方向和名称的情况下下载
【发布时间】:2023-04-01 03:37:01
【问题描述】:

我正在研究 python 和 splinter。我想使用 splinter 从单击事件中下载文件。我写了以下代码

from splinter import Browser
browser = Browser('chrome')
url = "download link"
browser.visit(url)

我想知道如何使用 splinter 知道文件的 URL 和名称进行下载

【问题讨论】:

    标签: python selenium selenium-webdriver selenium-chromedriver splinter


    【解决方案1】:

    Splinter 不参与文件的下载。

    也许您需要浏览页面以找到确切的 URL,然后使用常规的 requests 库进行下载:

    import requests
    
    url="some.download.link.com"
    result = requests.get(url)
    with open('file.pdf', 'wb') as f:
        f.write(result.content)
    

    【讨论】:

      猜你喜欢
      • 2014-08-10
      • 1970-01-01
      • 2022-08-03
      • 1970-01-01
      • 2017-04-26
      • 1970-01-01
      • 2014-07-31
      • 2016-06-16
      相关资源
      最近更新 更多