From 0b76120991af955d34a9376d44e1df719f7ac16c Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Wed, 9 Jan 2008 09:38:10 +0000 Subject: [PATCH] Do the second check for title only if there is HEAD. git-svn-id: file:///home/phd/archive/SVN/bookmarks_db/trunk@159 fdd5c36f-1aea-0310-aeeb-c58d7e2b6c23 --- Robots/parse_html_beautifulsoup.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Robots/parse_html_beautifulsoup.py b/Robots/parse_html_beautifulsoup.py index 3d5c44a..9b0fade 100644 --- a/Robots/parse_html_beautifulsoup.py +++ b/Robots/parse_html_beautifulsoup.py @@ -1,7 +1,7 @@ """ HTML Parser using BeautifulSoup - Written by BroytMann. Copyright (C) 2007 PhiloSoft Design + Written by BroytMann. Copyright (C) 2007, 2008 PhiloSoft Design """ import re @@ -72,13 +72,13 @@ def parse_html(filename, charset=None): except AttributeError: title = '' # HEAD but no TITLE - if not title: - head = root.html # Some sites put TITLE in HTML outside of HEAD + if (not title) and (head is not root.html): + # Some sites put TITLE in HTML outside of HEAD - try: - title = head.title.string.encode(_charset) - except AttributeError: - title = '' # HEAD but no TITLE + try: + title = root.html.title.string.encode(_charset) + except AttributeError: + title = '' # no TITLE in HTML too meta = head.find(_find_refresh, recursive=False) if meta: -- 2.39.5