This commit is contained in:
Kovid Goyal 2017-10-07 10:41:53 +05:30
parent 4b31a1eb1c
commit e972119109
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -55,13 +55,15 @@ class AssociatedPress(BasicNewsRecipe):
self.log('Processing section:', front, 'at', url)
data = self.index_to_soup(url, raw=True)
data = json.loads(data)
from pprint import pformat
open('/t/raw', 'wb').write(pformat(data))
cards = data.get('cards', ())
articles = []
for card in cards:
for article in card['contents']:
url = article['localLinkUrl']
title = article.get('flattenedFirstWords')
title = article.get('headline', article.get('flattenedFirstWords'))
if not title:
continue
title = title.split('\u2014')[-1]