schei? encoding

This commit is contained in:
Thorsten
2016-01-04 21:24:44 +01:00
parent 7fcaee8b1a
commit 1a2b81e083

View File

@@ -152,8 +152,12 @@ def extract_title(url):
if 'text/' != headers['content-type'][:len('text/')]:
return 1, headers['content-type']
if str != type(html_text):
html_text = str(html_text)
try:
charset = headers['content-type'].split(';')[1]
charset = charset.split("=")[1]
html_text = html_text.decode(charset)
except KeyError:
html_text = str(html_text)
result = re.match(r'.*?<title.*?>(.*?)</title>.*?', html_text, re.S | re.M | re.IGNORECASE)
if result: