W
W
wenzeslaus2021-07-12 21:18:56
Python
wenzeslaus, 2021-07-12 21:18:56

How to specify the path to download a file from a link?

And so hello, I have a code that allows you to download files from a link, but I would like to change it so that you can specify the path where to download this file. How to implement it correctly?

def downloadin(path, link):
    filename = link.split("/")[-1]
    dfile = requests.get(link)
    open(filename, "wb").write(dfile.content)

Naturally, the path argument is not specified anywhere now, but I would like that I could specify the path, and the file will be downloaded there

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ronald McDonald, 2021-07-12
@wenzeslaus

open( filename , "wb").write(dfile.content)

Highlighted with a bold. You need to do something like this:
open( your_path + filename , "wb").write(dfile.content)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question