"""HTML Parser using BeautifulSoup
This file is a part of Bookmarks database and Internet robot.
+
"""
__author__ = "Oleg Broytman <phd@phdru.name>"
-__copyright__ = "Copyright (C) 2007-2013 PhiloSoft Design"
+__copyright__ = "Copyright (C) 2007-2014 PhiloSoft Design"
__license__ = "GNU GPL"
__all__ = ['parse_html']
return j
-def _parse_html(filename, charset):
- infile = open(filename, 'r')
+def _parse_html(html_text, charset):
try:
- return BadDeclParser(infile, fromEncoding=charset)
+ return BadDeclParser(html_text, fromEncoding=charset)
except TypeError:
return None
- finally:
- infile.close()
-def parse_html(filename, charset=None, log=None):
- root = _parse_html(filename, charset)
+def parse_html(html_text, charset=None, log=None):
+ root = _parse_html(html_text, charset)
if root is None:
return None
_charset = root.originalEncoding
if _charset in ("ISO-8859-2", "windows-1252", "MacCyrillic"): # Replace default
_charset = DEFAULT_CHARSET
- root = _parse_html(filename, _charset)
+ root = _parse_html(html_text, _charset)
if root is None:
return None