I want to download a file using requests since its the best option from my research so far but I can't find out how to download the given url link without giving a file name.
import requests
url = 'https://www.python.org/static/img/python-logo.png'
fileName = 'D:\Python\dwnldPythonLogo.png'
req = requests.get(url)
file = open(fileName, 'wb')
for chunk in req.iter_content(100000):
file.write(chunk)
file.close()
The code above shows how to download it with a file name, is there a way to do it without a file name?
For example like this:
import requests
url = 'https://www.python.org/static/img/python-logo.png'
location = 'D:\Python\'
req = requests.get(url)
file = open(location, 'wb')
for chunk in req.iter_content(100000):
file.write(chunk)
file.close()