infile.close()
try:
- head = root.html.head
+ html = root.html
except AttributeError:
- if log: log("No HTML in root or no HEAD in HTML")
- return None
+ if log: log("No HTML in root")
+ html = root
+
+ if html is None:
+ html = root
+
+ try:
+ head = html.head
+ except AttributeError:
+ if log: log("No HEAD in HTML")
+ head = html
if head is None:
- head = root.html # Some sites put TITLE in HTML without HEAD
+ head = html # Some sites put TITLE in HTML without HEAD
_charset = root.originalEncoding
if _charset == "windows-1252": # Replace default
except AttributeError:
title = '' # HEAD but no TITLE
- if (not title) and (head is not root.html):
+ if (not title) and (head is not html):
# Some sites put TITLE in HTML outside of HEAD
try:
- title = root.html.title.string.encode(_charset)
+ title = html.title.string.encode(_charset)
except AttributeError:
title = '' # no TITLE in HTML too