Google Books don't like the garbeled HTML comments that could come from

hpfanficarchive, removing all comments
This commit is contained in:
asbjorn grandt
2015-01-23 22:57:19 +01:00
parent 8a9e2a43da
commit 15b246c21e
@@ -217,8 +217,13 @@ class HPFanficArchiveComAdapter(BaseSiteAdapter):
selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags.
div = soup.find('div', {'id' : 'story'})
if None == div:
raise exceptions.FailedToDownload("Error downloading Chapter: %s! Missing required element!" % url)
return self.utf8FromSoup(url,div)
# Comments can get garbled later in the process, preventing inport into some readers (specifically seen on Google Books)
# This will remove all html comemnts from the text body.
body = self.utf8FromSoup(url,div)
body = re.sub(r'<!--.+?-->', r'', body)
return body