Handling parser errors from lxml in icon fetching.

This commit is contained in:
Samuel Clay 2011-01-30 13:23:20 -05:00
parent 0175a8b26f
commit 7941e2f8b0

View file

@ -185,9 +185,13 @@ class IconImporter(object):
def _url_from_html(self, content):
url = None
if not content: return url
icon_path = lxml.html.fromstring(content).xpath(
'//link[@rel="icon" or @rel="shortcut icon"]/@href'
)
try:
icon_path = lxml.html.fromstring(content).xpath(
'//link[@rel="icon" or @rel="shortcut icon"]/@href'
)
except lxml.etree.ParserError:
return url
if icon_path:
if str(icon_path[0]).startswith('http'):
url = icon_path[0]