mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/unkn0w7n/calibre
This commit is contained in:
commit
d2f093824c
@ -19,13 +19,12 @@ def classes(classes):
|
|||||||
class Slate(BasicNewsRecipe):
|
class Slate(BasicNewsRecipe):
|
||||||
title = 'Slate'
|
title = 'Slate'
|
||||||
description = 'A general-interest publication offering analysis and commentary about politics, news and culture.'
|
description = 'A general-interest publication offering analysis and commentary about politics, news and culture.'
|
||||||
__author__ = 'Kovid Goyal'
|
__author__ = 'unkn0wn'
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
language = 'en'
|
language = 'en'
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
remove_attributes = ['style', 'height', 'width']
|
remove_attributes = ['style', 'height', 'width']
|
||||||
oldest_article = 2 # days
|
INDEX = 'https://slate.com/'
|
||||||
INDEX = 'https://slate.com'
|
|
||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
@ -52,16 +51,44 @@ class Slate(BasicNewsRecipe):
|
|||||||
img['src'] = img['data-src'] + '&width=600'
|
img['src'] = img['data-src'] + '&width=600'
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
feeds = [
|
def parse_index(self):
|
||||||
('News & Politics', 'https://slate.com/feeds/news-and-politics.rss'),
|
ans = []
|
||||||
('Culture', 'https://slate.com/feeds/culture.rss'),
|
for sectitle, url in (
|
||||||
('Technology', 'https://slate.com/feeds/technology.rss'),
|
('News & Politics', 'news-and-politics'),
|
||||||
('Business', 'https://slate.com/feeds/business.rss'),
|
('Culture', 'culture'),
|
||||||
('Human Interest', 'https://slate.com/feeds/human-interest.rss'),
|
('Technology', 'technology'),
|
||||||
('Others', 'https://slate.com/feeds/all.rss')
|
('Business', 'business'),
|
||||||
]
|
('Life', 'life'),
|
||||||
|
('Advice', 'advice'),
|
||||||
|
):
|
||||||
|
url = self.INDEX + url
|
||||||
|
self.log('\nFound section:', sectitle, url)
|
||||||
|
articles = self.slate_section_articles(url)
|
||||||
|
if articles:
|
||||||
|
ans.append((sectitle, articles))
|
||||||
|
return ans
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def slate_section_articles(self, url):
|
||||||
url = BasicNewsRecipe.get_article_url(self, article)
|
from datetime import date
|
||||||
if '/podcasts/' not in url:
|
soup = self.index_to_soup(url)
|
||||||
return url.split('?')[0]
|
ans = []
|
||||||
|
dt = date.today().strftime('/%Y/%m')
|
||||||
|
for a in soup.findAll('a', attrs={'href':lambda x: x and x.startswith(url + dt)}):
|
||||||
|
url = a['href']
|
||||||
|
head = a.find(attrs={'class':[
|
||||||
|
'section-feed-two-column__card-headline',
|
||||||
|
'section-feed-three-column__teaser-headline',
|
||||||
|
'section-feed-two-column__teaser-headline',
|
||||||
|
'topic-story__hed'
|
||||||
|
]})
|
||||||
|
if head:
|
||||||
|
title = self.tag_to_string(head).strip()
|
||||||
|
self.log('\t' + title)
|
||||||
|
self.log('\t\t' + url)
|
||||||
|
ans.append({'title': title, 'url': url})
|
||||||
|
return ans
|
||||||
|
|
||||||
|
def populate_article_metadata(self, article, soup, first):
|
||||||
|
summ = soup.find(attrs={'class':'article__dek'})
|
||||||
|
if summ:
|
||||||
|
article.summary = article.text_summary = self.tag_to_string(summ)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user