Skip to content

Commit

Permalink
Handling parser errors from lxml in icon fetching.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelclay committed Jan 30, 2011
1 parent 0175a8b commit 7941e2f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/rss_feeds/icon_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,13 @@ def _1(url):
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]
Expand Down

0 comments on commit 7941e2f

Please sign in to comment.