Catch HTMLParserErrors when we're trying to grab the <title>.

This commit is contained in:
James Vega 2005-05-07 03:24:10 +00:00
parent ae5b51fe97
commit 47179f8bc6

View File

@ -86,7 +86,11 @@ class Web(callbacks.PluginRegexp):
self.log.info('Couldn\'t snarf title of %u: %s.', url, e)
return
parser = Title()
try:
parser.feed(text)
except HTMLParserError:
self.log.debug('Unable to parse %u', url)
return
if parser.title is not None:
domain = utils.web.getDomain(url)
title = utils.web.htmlToText(parser.title.strip())
@ -158,7 +162,11 @@ class Web(callbacks.PluginRegexp):
size = conf.supybot.protocols.http.peekSize()
text = utils.web.getUrl(url, size=size)
parser = Title()
try:
parser.feed(text)
except HTMLParserError:
irc.reply(format('That URL appears to have no HTML title within '
'the first %i bytes.', size))
if parser.title is not None:
irc.reply(utils.web.htmlToText(parser.title.strip()))
else: