download file from url python 3 code example
Example 1: python download file from url
import requests
url = 'https://www.facebook.com/favicon.ico'
r = requests.get(url, allow_redirects=True)
open('facebook.ico', 'wb').write(r.content)
Example 2: download image from url python 3
import urllib.request
urllib.request.urlretrieve(url, filename)
Example 3: python3 download file
import urllib.request
print('Beginning file download with urllib2...')
url = 'http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg'
urllib.request.urlretrieve(url, '/Users/scott/Downloads/cat.jpg')