1import requests
2
3print('Beginning file download with requests')
4
5url = 'http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg'
6r = requests.get(url)
7
8with open('/Users/scott/Downloads/cat3.jpg', 'wb') as f:
9 f.write(r.content)
10
11# Retrieve HTTP meta-data
12print(r.status_code)
13print(r.headers['content-type'])
14print(r.encoding)
15