web-scraping-projets-infras.../download.py
François Pelletier c96c75b8c7 Initial commit
2018-12-25 21:23:56 -05:00

7 lines
No EOL
275 B
Python

def download(url):
try:
html = urllib.request.urlopen(urllib.request.Request(url,headers={'User-Agent': 'Mozilla'})).read()
except (URLError, HTTPError, ContentTooShortError) as e:
print('Download error:', e.reason)
html = None
return html