how to install urllib code example
Example 1: pip install urllib
pip install urllib3
Example 2: python urllib3 download file
import requests
print('Beginning file download with requests')
url = 'http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg'
r = requests.get(url)
with open('/Users/scott/Downloads/cat3.jpg', 'wb') as f:
f.write(r.content)
print(r.status_code)
print(r.headers['content-type'])
print(r.encoding)
Example 3: how to urllib3
>>> import urllib3
>>> http = urllib3.PoolManager()
>>> r = http.request('GET', 'http://httpbin.org/robots.txt')
>>> r.status
200
>>> r.data
'User-agent: *\nDisallow: /deny\n'