pythonseleniumselenium-webdriverselenium-chromedriversplinter

how to download with splinter knowing direction and name of the file


I am working on python and splinter. I want to download a file from clicking event using splinter. I wrote following code

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

I want to know how to download with splinter knowing URL and name of the file


Solution

  • Splinter is not involved in the download of a file.

    Maybe you need to navigate the page to find the exact URL, but then use the regular requests library for the download:

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