From: Oleg Broytman Date: Mon, 3 Mar 2008 15:22:14 +0000 (+0000) Subject: Fixed a bug in case there is no charset in META Content-Type. X-Git-Tag: v4.5.3~188 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=fa4cc9afb8d911873776c26576ce95ab08cda099;p=bookmarks_db.git Fixed a bug in case there is no charset in META Content-Type. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@188 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- diff --git a/Robots/parse_html_beautifulsoup.py b/Robots/parse_html_beautifulsoup.py index c45af2b..11db563 100644 --- a/Robots/parse_html_beautifulsoup.py +++ b/Robots/parse_html_beautifulsoup.py @@ -85,8 +85,12 @@ def parse_html(filename, charset=None): meta = head.find(_find_contenttype, recursive=False) if meta: - __charset = meta.get("content").lower().split('charset=')[1].split(';')[0] - meta_charset = _charset == __charset + try: + __charset = meta.get("content").lower().split('charset=')[1].split(';')[0] + except IndexError: # No charset in the META Content-Type + meta_charset = False + else: + meta_charset = _charset == __charset else: meta_charset = False