diff --git a/recipes/adventure_zone_pl.recipe b/recipes/adventure_zone_pl.recipe index ee5fd065ae..afb8e080d9 100644 --- a/recipes/adventure_zone_pl.recipe +++ b/recipes/adventure_zone_pl.recipe @@ -28,10 +28,10 @@ class Adventure_zone(BasicNewsRecipe): def skip_ad_pages(self, soup): skip_tag = soup.body.find(attrs={'class':'subject'}) skip_tag = skip_tag.findAll(name='a', href=True) - title = soup.title.renderContents().lower() + title = soup.title.renderContents().decode('utf-8').lower() if self._is_linked_text(title): for r in skip_tag: - word = r.renderContents() + word = r.renderContents().decode('utf-8') if not word: continue word = word.lower() diff --git a/recipes/berlin_policy_journal.recipe b/recipes/berlin_policy_journal.recipe index 6f9a2146b6..9e832c90a5 100644 --- a/recipes/berlin_policy_journal.recipe +++ b/recipes/berlin_policy_journal.recipe @@ -104,7 +104,7 @@ class BerlinPolicyJournal(BasicNewsRecipe): div = soup.find('div', {'class': 'meta-info'}) authors = '' for entry in div.findAll('span', {'class': 'entry-author'}): - authors = authors + entry.a.span.renderContents().strip() + ', ' - date = div.find('time').renderContents().strip() + authors = authors + entry.a.span.renderContents().decode('utf-8').strip() + ', ' + date = div.find('time').renderContents().decode('utf-8').strip() div.replaceWith('
s
if re.search('\n\n', comments):
@@ -4669,7 +4675,7 @@ class CatalogBuilder(object):
pTag.insert(0, p)
soup.insert(tsc, pTag)
tsc += 1
- comments = soup.renderContents(None)
+ comments = soup.decode_contents()
# Convert solo returns to
comments = re.sub('[\r\n]', '
', comments)
@@ -4726,7 +4732,7 @@ class CatalogBuilder(object):
result.insert(rtc, elem)
rtc += 1
- return result.renderContents(encoding=None)
+ return result.decode_contents()
def merge_comments(self, record):
""" Merge comments with custom column content.
@@ -4954,6 +4960,9 @@ class CatalogBuilder(object):
"""
self.update_progress_full_step(_("Saving NCX"))
+ ncx = self.ncx_soup.prettify(encoding='utf-8')
+ if isinstance(ncx, unicode_type):
+ ncx = ncx.encode('utf-8')
- outfile = open("%s/%s.ncx" % (self.catalog_path, self.opts.basename), 'w')
- outfile.write(self.ncx_soup.prettify())
+ with lopen("%s/%s.ncx" % (self.catalog_path, self.opts.basename), 'wb') as outfile:
+ outfile.write(ncx)
diff --git a/src/calibre/library/comments.py b/src/calibre/library/comments.py
index ec4279363f..5a176cb53c 100644
--- a/src/calibre/library/comments.py
+++ b/src/calibre/library/comments.py
@@ -131,7 +131,7 @@ def comments_to_html(comments):
for t in result.findAll(text=True):
t.replaceWith(prepare_string_for_xml(unicode_type(t)))
- return result.renderContents(encoding=None)
+ return result.decode_contents()
def markdown(val):