Skip to content

Instantly share code, notes, and snippets.

@openroomxyz
Created April 6, 2020 08:38
Show Gist options
  • Save openroomxyz/2b1fd6f57c99bbd8820e5901b6d637c7 to your computer and use it in GitHub Desktop.
Save openroomxyz/2b1fd6f57c99bbd8820e5901b6d637c7 to your computer and use it in GitHub Desktop.
Python : How to download a file and save it locally?
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