calibre/recipes/denver_post.recipe
Kovid Goyal 567040ee1e Perform PEP8 compliance checks on the entire codebase
Some bits of PEP 8 are turned off via setup.cfg
2016-07-29 21:25:17 +05:30

57 lines
1.6 KiB
Python

#!/usr/bin/env python2
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
from __future__ import (unicode_literals, division, absolute_import,
print_function)
from calibre.web.feeds.news import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
class DenverPost(BasicNewsRecipe):
title = u'Denver Post'
language = 'en'
__author__ = 'Kovid Goyal'
oldest_article = 1 # days
max_articles_per_feed = 20
no_stylesheets = True
use_embedded_content = False
keep_only_tags = [
dict(name='h1'),
classes('subheadline byline header-features article-body'),
]
remove_tags = [
classes('related'),
dict(attrs={'data-config-video-id': True}),
]
feeds = [
('Top Stories',
'http://feeds.denverpost.com/dp-news-topstories'),
('Business',
'http://feeds.denverpost.com/dp-business'),
('Sports',
'http://feeds.denverpost.com/dp-sports'),
('Lifestyles',
'http://feeds.denverpost.com/dp-lifestyles'),
('Politics',
'http://feeds.denverpost.com/dp-politics'),
('Entertainment',
'http://feeds.denverpost.com/dp-entertainment'),
]
def preprocess_html(self, soup):
for img in soup.findAll('img', attrs={'data-src': True}):
img['src'] = img['data-src']
del img['height']
del img['width']
return soup