]> git.phdru.name Git - bookmarks_db.git/blobdiff - parse_html/bkmk_ph_beautifulsoup4.py
Fix(Py3): Fix `basestring` compatibility
[bookmarks_db.git] / parse_html / bkmk_ph_beautifulsoup4.py
index 1ce543e828936284bc469f6037bf4f0a77ca14c4..33a2e18dd65376c1794c94d22b41c174212a24cb 100644 (file)
@@ -11,9 +11,10 @@ __license__ = "GNU GPL"
 __all__ = ['parse_html']
 
 
-import re
 from bs4 import BeautifulSoup
+
 from .bkmk_ph_util import HTMLParser
+from ..compat import string_type
 
 universal_charset = "utf-8"
 DEFAULT_CHARSET = "cp1251"  # Stupid default for Russian Cyrillic
@@ -55,8 +56,8 @@ def parse_html(html_text, charset=None, log=None):
         else:
             parts = []
             for part in title:
-                if not isinstance(part, basestring):
-                    part = unicode(part)
+                if not isinstance(part, string_type):
+                    part = part.decode()
                 parts.append(part.strip())
             title = ''.join(parts)