diff --git a/fanficdownloader/BeautifulSoup.py b/fanficdownloader/BeautifulSoup.py index 5414aa8..6913c20 100644 --- a/fanficdownloader/BeautifulSoup.py +++ b/fanficdownloader/BeautifulSoup.py @@ -114,6 +114,7 @@ class PageElement(object): """Contains the navigational information for some part of the page (either a tag or a piece of text)""" + ## Added for FFDL. bs3=True def setup(self, parent=None, previous=None): diff --git a/fanficdownloader/htmlcleanup.py b/fanficdownloader/htmlcleanup.py index 1544c81..325f5e1 100644 --- a/fanficdownloader/htmlcleanup.py +++ b/fanficdownloader/htmlcleanup.py @@ -56,7 +56,7 @@ def _replaceNotEntities(data): return p.sub(r'&\1', data) def stripHTML(soup): - if isinstance(soup,basestring) or soup.has_attr('bs3'): + if isinstance(soup,basestring) or hasattr(soup, 'bs3'): return removeAllEntities(re.sub(r'<[^>]+>','',"%s" % soup)).strip() else: # bs4 already converts all the entities to UTF8 chars. @@ -72,10 +72,9 @@ def removeAllEntities(text): # Remove < < and & return removeEntities(text).replace('<', '<').replace('>', '>').replace('&', '&') -def removeEntities(text): - +def removeEntities(text): if text is None: - return "" + return u"" if not isinstance(text,basestring): return unicode(text)