mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Web: HTMLParseError is deprecated/unused since Python 3.3 and removed in Python 3.5.
This commit is contained in:
parent
34d384bd67
commit
6ceec0c541
@ -44,10 +44,10 @@ from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
|||||||
_ = PluginInternationalization('Web')
|
_ = PluginInternationalization('Web')
|
||||||
|
|
||||||
if minisix.PY3:
|
if minisix.PY3:
|
||||||
from html.parser import HTMLParser, HTMLParseError
|
from html.parser import HTMLParser
|
||||||
from html.entities import entitydefs
|
from html.entities import entitydefs
|
||||||
else:
|
else:
|
||||||
from HTMLParser import HTMLParser, HTMLParseError
|
from HTMLParser import HTMLParser
|
||||||
from htmlentitydefs import entitydefs
|
from htmlentitydefs import entitydefs
|
||||||
|
|
||||||
class Title(HTMLParser):
|
class Title(HTMLParser):
|
||||||
@ -159,11 +159,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
parser = Title()
|
parser = Title()
|
||||||
try:
|
parser.feed(text)
|
||||||
parser.feed(text)
|
|
||||||
except HTMLParseError:
|
|
||||||
self.log.debug('Encountered a problem parsing %u. Title may '
|
|
||||||
'already be set, though', url)
|
|
||||||
if parser.title:
|
if parser.title:
|
||||||
domain = utils.web.getDomain(fd.geturl()
|
domain = utils.web.getDomain(fd.geturl()
|
||||||
if self.registryValue('snarferShowTargetDomain', channel)
|
if self.registryValue('snarferShowTargetDomain', channel)
|
||||||
@ -289,11 +285,7 @@ class Web(callbacks.PluginRegexp):
|
|||||||
if minisix.PY3 and isinstance(text, bytes):
|
if minisix.PY3 and isinstance(text, bytes):
|
||||||
irc.error(_('Could not guess the page\'s encoding. (Try '
|
irc.error(_('Could not guess the page\'s encoding. (Try '
|
||||||
'installing python-charade.)'), Raise=True)
|
'installing python-charade.)'), Raise=True)
|
||||||
try:
|
parser.feed(text)
|
||||||
parser.feed(text)
|
|
||||||
except HTMLParseError:
|
|
||||||
self.log.debug('Encountered a problem parsing %u. Title may '
|
|
||||||
'already be set, though', url)
|
|
||||||
if parser.title:
|
if parser.title:
|
||||||
title = utils.web.htmlToText(parser.title.strip())
|
title = utils.web.htmlToText(parser.title.strip())
|
||||||
if not [y for x,y in optlist if x == 'no-filter']:
|
if not [y for x,y in optlist if x == 'no-filter']:
|
||||||
|
Loading…
Reference in New Issue
Block a user