mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
c4b9994629
commit
553912d235
@ -61,31 +61,27 @@ class ForeignAffairsRecipe(BasicNewsRecipe):
|
|||||||
self.title = "Foreign Affairs ({})".format(date)
|
self.title = "Foreign Affairs ({})".format(date)
|
||||||
self.timefmt = u' [%s]' % date
|
self.timefmt = u' [%s]' % date
|
||||||
|
|
||||||
sec_start = soup.findAll(
|
for section in soup.findAll(attrs={'class':lambda x: x and 'magazine-list' in x.split()}):
|
||||||
'section', attrs={'class': re.compile(r'\bmagazine-list\b')})
|
|
||||||
for sec in sec_start:
|
|
||||||
articles = []
|
articles = []
|
||||||
section = self.tag_to_string(sec.find('h1'))
|
section_title = self.tag_to_string(section.find('h1'))
|
||||||
for article_block in sec.findAll('article'):
|
for h2 in section.findAll('h2'):
|
||||||
if article_block.find('a') is not None:
|
a = h2.parent
|
||||||
title = self.tag_to_string(article_block.div.a.h2)
|
if a.get('href'):
|
||||||
url = article_block.div.a['href']
|
title = self.tag_to_string(h2)
|
||||||
atr = article_block.findNext(
|
url = a['href']
|
||||||
'p', attrs={'class': 'author'})
|
atr = a.findNextSibling(attrs={'class':'author'})
|
||||||
if atr is not None:
|
author = self.tag_to_string(atr) if atr else ''
|
||||||
author = self.tag_to_string(atr)
|
desc = a.findNextSibling(attrs={'class': 'deck'})
|
||||||
else:
|
|
||||||
author = ''
|
|
||||||
desc = article_block.findNext(
|
|
||||||
'div', attrs={'class': 'deck'})
|
|
||||||
if desc is not None:
|
if desc is not None:
|
||||||
description = self.tag_to_string(desc)
|
description = self.tag_to_string(desc)
|
||||||
else:
|
else:
|
||||||
description = ''
|
description = ''
|
||||||
articles.append({'title': title, 'date': None, 'url': url,
|
articles.append({'title': title, 'url': url,
|
||||||
'description': description, 'author': author})
|
'description': description, 'author': author})
|
||||||
|
self.log(title)
|
||||||
|
self.log('\t' + url)
|
||||||
if articles:
|
if articles:
|
||||||
answer.append((section, articles))
|
answer.append((section_title, articles))
|
||||||
return answer
|
return answer
|
||||||
|
|
||||||
def clean_fa_html(self, root):
|
def clean_fa_html(self, root):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user