]> git.phdru.name Git - bookmarks_db.git/blobdiff - parse_html/bkmk_ph_lxml.py
Extract html redirect even if ther is no title
[bookmarks_db.git] / parse_html / bkmk_ph_lxml.py
index 79cbb01b49ec3c9f7c9171506afb82bf89364381..b14be408571ba53e0cfa5f60997394658ad2061b 100644 (file)
@@ -3,11 +3,8 @@
 This file is a part of Bookmarks database and Internet robot.
 """
 
-__version__ = "$Revision$"[11:-2]
-__revision__ = "$Id$"[5:-2]
-__date__ = "$Date$"[7:-2]
 __author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2010, 2011 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2010-2012 PhiloSoft Design"
 __license__ = "GNU GPL"
 
 __all__ = ['parse_html']
@@ -26,8 +23,6 @@ def parse_html(filename, charset=None, log=None):
     title = html_tree.findtext('head/title')
     if title is None:
         title = html_tree.findtext('title')
-        if title is None:
-            return None
 
     meta = html_tree.findall('head/meta')
     for m in meta:
@@ -43,7 +38,7 @@ def parse_html(filename, charset=None, log=None):
     else:
         meta_charset = False
 
-    if charset or meta_charset:
+    if title and (charset or meta_charset):
         title = title.encode(charset or meta_charset)
 
     for m in meta:
@@ -60,4 +55,6 @@ def parse_html(filename, charset=None, log=None):
     else:
         icon = None
 
+    if (title is None) and (refresh is None) and (icon is None):
+        return None
     return HTMLParser(charset, meta_charset, title, refresh, icon)