Get descriptions as well when parsing economist index page

This commit is contained in:
Kovid Goyal 2020-09-13 08:45:33 +05:30
parent 40e91596fb
commit a7789552df
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 4 deletions

View File

@ -268,8 +268,14 @@ class Economist(BasicNewsRecipe):
title = u'{}: {}'.format(*map(self.tag_to_string, spans))
else:
title = self.tag_to_string(a)
articles.append({'title': title, 'url': process_url(a['href'])})
self.log(' ', title, articles[-1]['url'])
desc = ''
desc_parent = a.findParent('div')
if desc_parent is not None:
p = desc_parent.find(itemprop='description')
if p is not None:
desc = self.tag_to_string(p)
articles.append({'title': title, 'url': process_url(a['href']), 'description': desc})
self.log(' ', title, articles[-1]['url'], '\n ', desc)
if articles:
feeds.append((secname, articles))
return feeds

View File

@ -268,8 +268,14 @@ class Economist(BasicNewsRecipe):
title = u'{}: {}'.format(*map(self.tag_to_string, spans))
else:
title = self.tag_to_string(a)
articles.append({'title': title, 'url': process_url(a['href'])})
self.log(' ', title, articles[-1]['url'])
desc = ''
desc_parent = a.findParent('div')
if desc_parent is not None:
p = desc_parent.find(itemprop='description')
if p is not None:
desc = self.tag_to_string(p)
articles.append({'title': title, 'url': process_url(a['href']), 'description': desc})
self.log(' ', title, articles[-1]['url'], '\n ', desc)
if articles:
feeds.append((secname, articles))
return feeds