mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Slate
This commit is contained in:
parent
a2fe4afafe
commit
4311cae31a
@ -32,7 +32,7 @@ class Slate(BasicNewsRecipe):
|
|||||||
classes('article__header article__content'),
|
classes('article__header article__content'),
|
||||||
]
|
]
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name='ul', attrs={'class':"social-share"}),
|
classes('social-share slate-ad newsletter-signup in-article-recirc'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
@ -53,7 +53,7 @@ class Slate(BasicNewsRecipe):
|
|||||||
('Double X', '/articles/double_x.html'),
|
('Double X', '/articles/double_x.html'),
|
||||||
):
|
):
|
||||||
url = self.INDEX + url
|
url = self.INDEX + url
|
||||||
self.log('\nFound section:', sectitle)
|
self.log('\nFound section:', sectitle, url)
|
||||||
articles = self.slate_section_articles(self.index_to_soup(url))
|
articles = self.slate_section_articles(self.index_to_soup(url))
|
||||||
if articles:
|
if articles:
|
||||||
ans.append((sectitle, articles))
|
ans.append((sectitle, articles))
|
||||||
@ -63,24 +63,23 @@ class Slate(BasicNewsRecipe):
|
|||||||
|
|
||||||
def slate_section_articles(self, soup):
|
def slate_section_articles(self, soup):
|
||||||
ans = []
|
ans = []
|
||||||
main = soup.find('article', attrs={'class': 'main'})
|
main = soup.find('section', **classes('main'))
|
||||||
if main is None:
|
if main is None:
|
||||||
return ans
|
return ans
|
||||||
for a in main.findAll('a', attrs={'class': 'primary'}):
|
for div in main.findAll(**classes('section-feed__item')):
|
||||||
|
a = div.find('a')
|
||||||
url = a['href']
|
url = a['href']
|
||||||
if url.endswith('/'):
|
if url.endswith('/'):
|
||||||
continue
|
continue
|
||||||
p = a.parent
|
h = a.find(['h2', 'h3', 'h4'])
|
||||||
title = p.find(attrs={'class': 'hed'})
|
title = self.tag_to_string(h)
|
||||||
if title is None:
|
|
||||||
continue
|
|
||||||
title = self.tag_to_string(title)
|
|
||||||
span = p.find(attrs={'class': 'byline'})
|
|
||||||
desc = ''
|
desc = ''
|
||||||
if span is not None:
|
for q in ('byline', 'dek'):
|
||||||
desc = self.tag_to_string(span)
|
span = div.find(attrs={'class': lambda x: x and ('-' + q) in x})
|
||||||
|
if span is not None:
|
||||||
|
desc += self.tag_to_string(span).strip()
|
||||||
self.log('\t' + title)
|
self.log('\t' + title)
|
||||||
self.log('\t\t' + url)
|
self.log('\t\t' + url)
|
||||||
ans.append({'title': title, 'description': desc,
|
ans.append({'title': title, 'description': desc.strip(),
|
||||||
'date': '', 'url': url})
|
'date': '', 'url': url})
|
||||||
return ans
|
return ans
|
||||||
|
Loading…
x
Reference in New Issue
Block a user