web-scraping-projets-infras.../download.py

7 lines
275 B
Python
Raw Normal View History

2018-12-25 21:23:56 -05:00
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