Debian Codegraph @

recipes/salon.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 from __future__ import absolute_import, division, print_function, unicode_literals
4
5 from calibre.web.feeds.news import BasicNewsRecipe
6
7
8 def classes(classes):
9 q = frozenset(classes.split(' '))
10 return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
11
12
13 class Salon_com(BasicNewsRecipe):
14 title = 'Salon.com'
15 __author__ = 'ebrandon'
16 description = 'Salon.com - Breaking news, opinion, politics, entertainment, sports and culture.'
17 timefmt = ' [%b %d, %Y]'
18 language = 'en'
19 oldest_article = 7
20 max_articles_per_feed = 100
21 no_stylesheets = True
22 # auto_cleanup = True
23 # auto_cleanup_keep = '//div[@id="image-id"]'
24 ignore_duplicate_articles = {'title', 'url'}
25 remove_empty_feeds = True
26
27 keep_only_tags = [
28 dict(itemprop=['headline', 'description']),
29 classes('article-content title-container article_rail_wrapper cover-wrapper article_img_desc'),
30 ]
31
32 remove_tags = [
33 classes('social_comments_app_wrapper related_article layout_template_wrapper writer-container right-rail topic_explore_box'),
34 dict(name=['object', 'link', 'embed', 'iframe', 'meta']),
35 dict(id=['social-left', 'article-footer-wrap']),
36 dict(name='nav', attrs={'class': 'subheading'}),
37 ]
38 remove_attributes = ['lang', 'style']
39
40 feeds = [
41 # ('News', 'http://www.salon.com/category/news/feed/rss/'),
42 # ('Politics', 'http://www.salon.com/category/politics/feed/rss/'),
43 # ('Business', 'http://www.salon.com/category/business/feed/rss/'),
44 # ('Technology', 'http://www.salon.com/category/technology/feed/rss/'),
45 # ('Innovation', 'http://www.salon.com/category/innovation/feed/rss/'),
46 # ('Sustainability', 'http://www.salon.com/category/sustainability/feed/rss/'),
47 # ('Entertainment', 'http://www.salon.com/category/entertainment/feed/rss/'),
48 # ('Life', 'http://www.salon.com/category/life/feed/rss/'),
49 ('News and Politics', 'https://www.salon.com/category/news-and-politics/feed'),
50 ('Culture', 'http://www.salon.com/category/culture/feed/'),
51 ('Science & Health', 'https://www.salon.com/category/science-and-health/feed/'),
52 ('Food', 'https://www.salon.com/category/food/feed/'),
53 ('Money', 'https://www.salon.com/category/money/feed/'),
54 ('Life Stories', 'https://www.salon.com/category/life-stories/feed/'),
55 ('Reviews', 'https://www.salon.com/category/reviews/feed/'),
56 ('Top', 'http://www.salon.com/feed/'),
57 ]
58
59 def get_browser(self, *args, **kwargs):
60 br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
61 br.set_handle_gzip(True)
62 return br