1
0
Fork 0
mirror of synced 2024-06-24 17:10:21 +12:00

add timeout to title fetching

This commit is contained in:
Nick Sweeting 2019-01-23 01:06:59 -05:00
parent e1be96e597
commit db0461ec4e

View file

@ -234,7 +234,7 @@ def fetch_page_title(url, default=True):
default = url
try:
html_content = urllib.request.urlopen(url).read().decode('utf-8')
html_content = urllib.request.urlopen(url, timeout=10).read().decode('utf-8')
match = re.search('<title>(.*?)</title>', html_content)
return match.group(1) if match else default or None