]> git.phdru.name Git - bookmarks_db.git/blobdiff - parse_html/bkmk_ph_html5.py
Fix(Py3): Fix HTML parsers
[bookmarks_db.git] / parse_html / bkmk_ph_html5.py
index 68c1ababbb106f33a14d08e3c51d9e8d19e17573..1fabd82166611fcf5c480463296e07390c906be1 100644 (file)
@@ -17,8 +17,11 @@ from .bkmk_ph_util import HTMLParser
 
 def parse_html(html_text, charset=None, log=None):
     parser = HTML5Parser()
-    html_tree = parser.parse(
-        html_text, encoding=charset, parseMeta=bool(charset))
+    if isinstance(html_text, bytes):
+        html_tree = parser.parse(
+            html_text, encoding=charset, parseMeta=bool(charset))
+    else:
+        html_tree = parser.parse(html_text)
 
     html = None
     if hasattr(html_tree, 'childNodes'):