mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-29 15:01:05 -05:00
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:
commit
9f10f08b2e
@ -155,9 +155,10 @@ class Web(callbacks.PluginRegexp):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
parser.feed(text)
|
parser.feed(text)
|
||||||
|
parser.close()
|
||||||
title = parser.title
|
title = parser.title
|
||||||
if title:
|
if title:
|
||||||
title = utils.web.htmlToText(parser.title.strip())
|
title = utils.web.htmlToText(title.strip())
|
||||||
elif raiseErrors:
|
elif raiseErrors:
|
||||||
if len(text) < size:
|
if len(text) < size:
|
||||||
irc.reply(_('That URL appears to have no HTML title.'))
|
irc.reply(_('That URL appears to have no HTML title.'))
|
||||||
|
@ -67,7 +67,7 @@ class WebTestCase(ChannelPluginTestCase):
|
|||||||
'title http://www.youtube.com/watch?v=x4BtiqPN4u8')
|
'title http://www.youtube.com/watch?v=x4BtiqPN4u8')
|
||||||
self.assertResponse(
|
self.assertResponse(
|
||||||
'title http://www.thefreedictionary.com/don%27t',
|
'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):
|
def testTitleSnarfer(self):
|
||||||
try:
|
try:
|
||||||
|
@ -254,6 +254,7 @@ def htmlToText(s, tagReplace=' '):
|
|||||||
pass
|
pass
|
||||||
x = HtmlToText(tagReplace)
|
x = HtmlToText(tagReplace)
|
||||||
x.feed(s)
|
x.feed(s)
|
||||||
|
x.close()
|
||||||
return x.getText()
|
return x.getText()
|
||||||
|
|
||||||
def mungeEmail(s):
|
def mungeEmail(s):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user