Update Slate

This commit is contained in:
Kovid Goyal 2018-04-12 08:26:37 +05:30
parent bee21462e0
commit 8665b6c870
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -10,6 +10,12 @@ calibre recipe for slate.com
from calibre.web.feeds.recipes import BasicNewsRecipe from calibre.web.feeds.recipes import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
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.'
@ -20,23 +26,20 @@ class Slate(BasicNewsRecipe):
encoding = 'utf-8' encoding = 'utf-8'
masthead_url = 'http://img.slate.com/images/redesign2008/slate_logo.gif' masthead_url = 'http://img.slate.com/images/redesign2008/slate_logo.gif'
remove_attributes = ['style'] remove_attributes = ['style']
INDEX = 'http://slate.com' INDEX = 'https://slate.com'
compress_news_images = True compress_news_images = True
keep_only_tags = [ keep_only_tags = [
dict(name='header', attrs={'class': 'article-header'}), classes('article__header article__content'),
dict(name='section', attrs={
'class': lambda x: x and 'content' == x.strip()}),
] ]
remove_tags = [ remove_tags = [
dict(id='header_social'), dict(name='ul', attrs={'class':"social-share"}),
dict(attrs={'class': ['prop-name', 'prop-desc', 'authorbox',
'twitter', 'email', 'facebook', 'follow-links', 'join-in']}),
dict(attrs={'class': lambda x: x and 'sharing-buttons' in x.split()}),
] ]
def print_version(self, url): def preprocess_html(self, soup):
return url.replace('.html', '.single.html') for img in soup.findAll('img', attrs={'data-srcset': True}):
img['src'] = img['data-srcset'].split()[0]
return soup
def parse_index(self): def parse_index(self):
ans = [] ans = []