From 3105d2bd328e227d6e168b257496409530a86c05 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 23 May 2014 08:45:02 +0530 Subject: [PATCH] ... --- src/calibre/ebooks/readability/htmls.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/readability/htmls.py b/src/calibre/ebooks/readability/htmls.py index f882f95254..b30196b3b2 100644 --- a/src/calibre/ebooks/readability/htmls.py +++ b/src/calibre/ebooks/readability/htmls.py @@ -36,7 +36,10 @@ def norm_title(title): return normalize_entities(normalize_spaces(title)) def get_title(doc): - title = doc.find('.//title').text + try: + title = doc.find('.//title').text + except AttributeError: + title = None if not title: return '[no-title]' @@ -101,7 +104,7 @@ def shorten_title(doc): return title def get_body(doc): - [ elem.drop_tree() for elem in doc.xpath('.//script | .//link | .//style') ] + [elem.drop_tree() for elem in doc.xpath('.//script | .//link | .//style')] raw_html = unicode(tostring(doc.body or doc)) return clean_attributes(raw_html)