X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=Robots%2Fparse_html_beautifulsoup.py;h=1fa4dc358e723481cfa667767ffb9c6f49318b58;hb=ae234692fece76a64f3275948ab9b820f80606de;hp=a7df16f926e94c1812617026885391a620eb119f;hpb=f8c96fe94544f486e9e76640d16fc355daa4db70;p=bookmarks_db.git diff --git a/Robots/parse_html_beautifulsoup.py b/Robots/parse_html_beautifulsoup.py index a7df16f..1fa4dc3 100644 --- a/Robots/parse_html_beautifulsoup.py +++ b/Robots/parse_html_beautifulsoup.py @@ -81,7 +81,7 @@ def parse_html(filename, charset=None, log=None): return None if title.string: - title = title.string.encode(_charset) + title = title.string else: parts = [] for part in title: @@ -90,6 +90,9 @@ def parse_html(filename, charset=None, log=None): parts.append(part.strip()) title = ''.join(parts) + if _charset or meta_charset: + title = title.encode(_charset or meta_charset) + meta = head.find(_find_contenttype, recursive=False) if meta: try: @@ -105,9 +108,6 @@ def parse_html(filename, charset=None, log=None): else: meta_charset = False - if charset or meta_charset: - title = title.encode(charset or meta_charset) - meta = head.find(_find_refresh, recursive=False) if meta: refresh = meta.get("content")