Commit 37ab5b7f authored by Svetlana Tkachenko's avatar Svetlana Tkachenko
Browse files

Support multiline title in urltitle (relates to issue #30)

parent 62a69b33
#import urllib
import re
import urllib.request
import html.parser
......@@ -31,8 +31,9 @@ class Urltitle(object):
request = urllib.request.Request(url, headers={'user-agent': 'guppy ' + self.server.config["version"]})
s = urllib.request.urlopen(request)
title = s.read().decode('utf-8', 'replace').split("<title>")[1].split("</title>")[0]
title = html.parser.HTMLParser().unescape(title)
return url + " - " + title
# title = html.parser.HTMLParser().unescape(title)
title = re.sub("[\n\r\x01]+", "", html.parser.HTMLParser().unescape(title))
return url + " - " + title.strip()
except:
return None
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment