Dont use str(soup)

This commit is contained in:
Kovid Goyal 2019-03-24 15:15:21 +05:30
parent 9395c717ed
commit a137e676a6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 6 deletions

View File

@ -44,7 +44,7 @@ class LondonReviewOfBooksPayed(BasicNewsRecipe):
articles = [] articles = []
soup = self.index_to_soup(self.INDEX) soup = self.index_to_soup(self.INDEX)
cover_item = soup.find('p', attrs={'class': 'cover'}) cover_item = soup.find('p', attrs={'class': 'cover'})
dates = str(soup.find('span', attrs={'class': 'coverdate'})) dates = type(u'')(soup.find('span', attrs={'class': 'coverdate'}))
newdates = re.sub(r'\<.*\>', '', re.split('<br />', dates)[1]) newdates = re.sub(r'\<.*\>', '', re.split('<br />', dates)[1])
self.timefmt = ' [%s]' % newdates self.timefmt = ' [%s]' % newdates
lrbtitle = self.title lrbtitle = self.title

View File

@ -43,7 +43,7 @@ class SmileZilla(BasicNewsRecipe):
if img['src'].startswith('/'): if img['src'].startswith('/'):
img['src'] = 'http://www.smilezilla.com' + img['src'] img['src'] = 'http://www.smilezilla.com' + img['src']
pt = PersistentTemporaryFile('.html') pt = PersistentTemporaryFile('.html')
pt.write(str(soup.html).encode(self.encoding)) pt.write(type(u'')(soup.html).encode(self.encoding))
pt.close() pt.close()
cache[url] = pt.name cache[url] = pt.name
return soup return soup
@ -63,7 +63,7 @@ class SmileZilla(BasicNewsRecipe):
section_title = self._get_section_title(soup) section_title = self._get_section_title(soup)
todays_jokes = [] todays_jokes = []
for hr in enumerate(jokes_entry.findAll('hr')): for hr in enumerate(jokes_entry.findAll('hr')):
title = 'Joke ' + str(hr[0] + 1) title = 'Joke ' + type(u'')(hr[0] + 1)
url = self.JOKES_INDEX url = self.JOKES_INDEX
todays_jokes.append({'title': title, 'url': url, todays_jokes.append({'title': title, 'url': url,
'description': '', 'date': ''}) 'description': '', 'date': ''})
@ -75,7 +75,7 @@ class SmileZilla(BasicNewsRecipe):
todays_stories = [] todays_stories = []
for hr in enumerate(entry.findAll('hr')): for hr in enumerate(entry.findAll('hr')):
title = 'Story ' + str(hr[0] + 1) title = 'Story ' + type(u'')(hr[0] + 1)
current = hr[1] current = hr[1]
while True: while True:
current = current.findPrevious() current = current.findPrevious()
@ -105,7 +105,7 @@ class SmileZilla(BasicNewsRecipe):
entry = self._get_entry(soup) entry = self._get_entry(soup)
soup2 = BeautifulSoup('<html><head></head><body></body></html>') soup2 = BeautifulSoup('<html><head></head><body></body></html>')
body = soup2.find('body') body = soup2.find('body')
entries = str(entry).split('<hr />') entries = type(u'')(entry).split('<hr />')
body.insert(0, entries[count - 1]) body.insert(0, entries[count - 1])
return str(soup2) return type(u'')(soup2)