I am newcomer in Python and found a code that downloads and saves data as demofile.csv
import requests
url = "https://example.com/demofile"
r = requests.get(url)
filename = url.split('/')[-1]
with open(filename+".csv", "wb") as code:
code.write(r.content)
Now, I don't want to explicitly specify any name. I just want that URL is opened through Python script and the file gets downloaded with its default name and type(the one that comes when we manually download the file).
Also, this file should be saved in some other directory instead of the folder in which python code is saved.
Kindly help in this.