Created
April 6, 2020 08:38
-
-
Save openroomxyz/2b1fd6f57c99bbd8820e5901b6d637c7 to your computer and use it in GitHub Desktop.
Python : How to download a file and save it locally?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import shutil | |
URL = "https://" | |
save_as = 'img.png' | |
response = requests.get(URL) | |
response = requests.get(URL, stream=True) | |
with open(save_as, 'wb') as out_file: | |
shutil.copyfileobj(response.raw, out_file) | |
del response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment