]> git.phdru.name Git - bookmarks_db.git/commitdiff
Calculate if the charset came from HTTP or from HTML meta.
authorOleg Broytman <phd@phdru.name>
Sun, 16 Dec 2007 19:55:26 +0000 (19:55 +0000)
committerOleg Broytman <phd@phdru.name>
Sun, 16 Dec 2007 19:55:26 +0000 (19:55 +0000)
git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@108 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23

Robots/parse_html_beautifulsoup.py

index e0129fd1d4cb3c7b34f69f8c772946c04afab645..130b20a7ca8f53a472526125be0390b029251c78 100644 (file)
@@ -23,9 +23,9 @@ def parse_html(filename, charset=None):
    root = BeautifulSoup(infile, fromEncoding=charset)
    infile.close()
 
-   charset = root.originalEncoding
+   _charset = root.originalEncoding
    try:
-      title = root.html.head.title.string.encode(charset)
+      title = root.html.head.title.string.encode(_charset)
    except AttributeError:
       title = ''
 
@@ -49,7 +49,7 @@ def parse_html(filename, charset=None):
       else:
          icon = None
 
-   parser = BSoupParser(charset, False, title, refresh, icon)
+   parser = BSoupParser(_charset, _charset == charset, title, refresh, icon)
    return parser
 
 def _find_refresh(Tag):