Python 如何使用splinter下载,知道文件的方向和名称

Python 如何使用splinter下载,知道文件的方向和名称,python,selenium,selenium-webdriver,selenium-chromedriver,splinter,Python,Selenium,Selenium Webdriver,Selenium Chromedriver,Splinter,我正在研究python和splinter。我想使用splinter从单击事件下载一个文件。我编写了以下代码 from splinter import Browser browser = Browser('chrome') url = "download link" browser.visit(url) 我想知道如何使用splinter下载,知道文件的URL和名称,splinter不参与文件的下载 也许您需要导航页面以找到准确的URL,但随后使用常规的请求库进行下载: import reques

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

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

我想知道如何使用splinter下载,知道文件的URL和名称,splinter不参与文件的下载

也许您需要导航页面以找到准确的URL,但随后使用常规的
请求
库进行下载:

import requests

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