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
bee21462e0
commit
8665b6c870
@ -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 = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user