Merge pull request #1175 from Ban3/python350-htmlparser-fixes

Web & utils.web: Fix for HTMLParser in Python 3.5.0
This commit is contained in:
Valentin Lorentz 2015-10-22 17:18:40 +02:00
commit 9f10f08b2e
3 changed files with 4 additions and 2 deletions

View File

@ -155,9 +155,10 @@ class Web(callbacks.PluginRegexp):
else:
return None
parser.feed(text)
parser.close()
title = parser.title
if title:
title = utils.web.htmlToText(parser.title.strip())
title = utils.web.htmlToText(title.strip())
elif raiseErrors:
if len(text) < size:
irc.reply(_('That URL appears to have no HTML title.'))

View File

@ -67,7 +67,7 @@ class WebTestCase(ChannelPluginTestCase):
'title http://www.youtube.com/watch?v=x4BtiqPN4u8')
self.assertResponse(
'title http://www.thefreedictionary.com/don%27t',
"don't - definition of don't by The Free Dictionary")
"Don't - definition of don't by The Free Dictionary")
def testTitleSnarfer(self):
try:

View File

@ -254,6 +254,7 @@ def htmlToText(s, tagReplace=' '):
pass
x = HtmlToText(tagReplace)
x.feed(s)
x.close()
return x.getText()
def mungeEmail(s):