Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to redirect where requests library downloads file python

import requests
 
file_url = 'https://www.journaldev.com/wp-content/uploads/2019/08/Python-Tutorial.png'
 
file_object = requests.get(file_url)
 
with open('Python-Tutorial.png', 'wb') as local_file:
    local_file.write(file_object.content)

#The file will be downloaded in the same directory as the Python script.
#If you want to change the directory location,
#you can provide a complete path or relative path in the open() function call.
    
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #redirect #requests #library #downloads #file #python
ADD COMMENT
Topic
Name
2+2 =