This commit is contained in:
Kovid Goyal 2017-02-11 17:31:19 +05:30
parent e06288bc50
commit 5d35c23c5e
2 changed files with 12 additions and 12 deletions

View File

@ -147,17 +147,17 @@ class Economist(BasicNewsRecipe):
secname = self.tag_to_string(section) secname = self.tag_to_string(section)
self.log(secname) self.log(secname)
for a in section.findNextSiblings('a', href=True): for a in section.findNextSiblings('a', href=True):
title = ( spans = a.findAll('span')
self.tag_to_string( if len(spans) == 2:
a.find(attrs={'class': 'print-edition__link-title'}) title = '{}: {}'.format(*map(self.tag_to_string, spans))
) or self.tag_to_string(a) else:
) title = self.tag_to_string(a)
articles.append({'title': title, 'url': process_url(a['href'])}) articles.append({'title': title, 'url': process_url(a['href'])})
self.log(' ', title, articles[-1]['url']) self.log(' ', title, articles[-1]['url'])
if articles: if articles:
feeds.append((secname, articles)) feeds.append((secname, articles))
return feeds return feeds
self.economist_parse_old_index(soup) return self.economist_parse_old_index(soup)
def economist_parse_old_index(self, soup): def economist_parse_old_index(self, soup):
feeds = OrderedDict() feeds = OrderedDict()

View File

@ -147,17 +147,17 @@ class Economist(BasicNewsRecipe):
secname = self.tag_to_string(section) secname = self.tag_to_string(section)
self.log(secname) self.log(secname)
for a in section.findNextSiblings('a', href=True): for a in section.findNextSiblings('a', href=True):
title = ( spans = a.findAll('span')
self.tag_to_string( if len(spans) == 2:
a.find(attrs={'class': 'print-edition__link-title'}) title = '{}: {}'.format(*map(self.tag_to_string, spans))
) or self.tag_to_string(a) else:
) title = self.tag_to_string(a)
articles.append({'title': title, 'url': process_url(a['href'])}) articles.append({'title': title, 'url': process_url(a['href'])})
self.log(' ', title, articles[-1]['url']) self.log(' ', title, articles[-1]['url'])
if articles: if articles:
feeds.append((secname, articles)) feeds.append((secname, articles))
return feeds return feeds
self.economist_parse_old_index(soup) return self.economist_parse_old_index(soup)
def economist_parse_old_index(self, soup): def economist_parse_old_index(self, soup):
feeds = OrderedDict() feeds = OrderedDict()