Debian Codegraph @

recipes/science_x.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 """
4 https://sciencex.com/
5 """
6
7 from calibre.web.feeds.news import BasicNewsRecipe
8
9
10 class scix(BasicNewsRecipe):
11 title = 'Science X'
12 description = (
13 'Science X is a network of high-quality websites that provides the most complete and comprehensive '
14 'daily coverage of science, technology, and medical news. Articles from phys.org, medicalxpress.com'
15 '& techxplore.com'
16 )
17 language = 'en'
18 __author__ = 'unkn0wn'
19 oldest_article = 1 # days
20 max_articles_per_feed = 50
21 encoding = 'utf-8'
22 remove_attributes = ['height', 'width']
23 ignore_duplicate_articles = {'url', 'title'}
24
25 extra_css = '''
26 #figure {text-align:center; font-size:small;}
27 em, blockquote {color:#202020;}
28 .article__info, .article-byline, .article-main__more, .d-print-block {font-size:small; color:#404040;}
29 '''
30
31 recipe_specific_options = {
32 'days': {
33 'short': 'Oldest article to download from this news source. In days ',
34 'long': 'For example, 0.5, gives you articles from the past 12 hours',
35 'default': str(oldest_article),
36 }
37 }
38
39 def __init__(self, *args, **kwargs):
40 BasicNewsRecipe.__init__(self, *args, **kwargs)
41 d = self.recipe_specific_options.get('days')
42 if d and isinstance(d, str):
43 self.oldest_article = float(d)
44
45 resolve_internal_links = True
46 remove_empty_feeds = True
47
48 keep_only_tags = [dict(name='article', attrs={'class': 'news-article'})]
49
50 feeds = [
51 ('Tech Xplore', 'https://techxplore.com/rss-feed/'),
52 ('Medical Xpress', 'https://medicalxpress.com/rss-feed/'),
53 ('Phys.org', 'https://phys.org/rss-feed/'),
54 # https://medicalxpress.com/feeds/
55 # https://techxplore.com/feeds/
56 ]
57
58 def preprocess_html(self, soup):
59 for figure in soup.findAll('figure'):
60 figure['id'] = 'figure'
61 return soup