Strip html title
This commit is contained in:
1 parent
ef99764a5d
commit
cb9edb2ccf
1 file changed
+3
-2
@@ -189,7 +189,8 @@ class IRCActions():
|
|||||||
url = urlmatch.group()
|
url = urlmatch.group()
|
||||||
try:
|
try:
|
||||||
i = urllib2.urlopen(url, timeout=3)
|
i = urllib2.urlopen(url, timeout=3)
|
||||||
except:
|
except Exception as e:
|
||||||
|
log(e)
|
||||||
self.bot.msgReply(nick, channel, reply + "Timeout")
|
self.bot.msgReply(nick, channel, reply + "Timeout")
|
||||||
return
|
return
|
||||||
statuscode = i.getcode()
|
statuscode = i.getcode()
|
||||||
@@ -203,7 +204,7 @@ class IRCActions():
|
|||||||
tree = lxml.html.fromstring(partialhtml)
|
tree = lxml.html.fromstring(partialhtml)
|
||||||
title = tree.find(".//title")
|
title = tree.find(".//title")
|
||||||
if title is not None and title.text is not None:
|
if title is not None and title.text is not None:
|
||||||
reply += "[%s]" % title.text
|
reply += "[%s]" % title.text.strip()
|
||||||
# DEBUG
|
# DEBUG
|
||||||
if title is None:
|
if title is None:
|
||||||
reply += "<title is none>"
|
reply += "<title is none>"
|
||||||
|
|||||||
Reference in new issue
Block a user