Skip to content

Instantly share code, notes, and snippets.

@biranchi2018
Last active Jun 5, 2021
Embed
What would you like to do?
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