1import urllib2
2
3filedata = urllib2.urlopen('http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg')
4datatowrite = filedata.read()
5
6with open('/Users/scott/Downloads/cat2.jpg', 'wb') as f:
7 f.write(datatowrite)
8
1import urllib.request
2
3print('Beginning file download with urllib2...')
4
5url = 'http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg'
6urllib.request.urlretrieve(url, '/Users/scott/Downloads/cat.jpg')
7