Skip to content

Instantly share code, notes, and snippets.

@biranchi2018
Last active June 5, 2021 12:56
Show Gist options
  • Save biranchi2018/7127ab082fca7c42cc59b1a693fc2571 to your computer and use it in GitHub Desktop.
Save biranchi2018/7127ab082fca7c42cc59b1a693fc2571 to your computer and use it in GitHub Desktop.
Download a file using Python
import requests
url = 'https://www.facebook.com/favicon.ico'
r = requests.get(url, allow_redirects=True)
with open('facebook.ico', 'wb') as f:
f.write(r.content)
#===================================================
import urllib
urllib.request.urlretrieve("http://randomsite.com/file.gz", "file.gz")
#===================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment