From fa4cc9afb8d911873776c26576ce95ab08cda099 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 3 Mar 2008 15:22:14 +0000 Subject: [PATCH] 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 --- Robots/parse_html_beautifulsoup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 -- 2.39.2