File: lescienze.recipe

package info (click to toggle)
calibre 2.75.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 371,080 kB
  • ctags: 58,531
  • sloc: python: 428,639; ansic: 117,109; cpp: 45,255; xml: 42,660; sql: 549; sh: 459; makefile: 128
file content (49 lines) | stat: -rw-r--r-- 1,383 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python2
__license__ = 'GPL v3'
__author__ = 'Daniele Forsi'

from calibre.web.feeds.recipes import BasicNewsRecipe


class LeScienze(BasicNewsRecipe):
    title = 'Le Scienze'
    description = 'Edizione italiana di Scientific American'
    publication_type = 'magazine'
    language = 'it'
    conversion_options = {
        'publisher': 'Le Scienze S.p.A.',
        'tags': 'science',
    }

    INDEX = 'http://www.lescienze.it/utility/2011/10/17/news/lista_rss-589690/'
    masthead_url = 'http://www.lescienze.it/static/images/logo-le-scienze.png'
    no_stylesheets = True
    extra_css = '''
    .img-left,.img-right{font-style:italic;font-size:75%;padding:1em;margin:auto;}
    .summary{font-style:italic;font-size:120%;}
    '''
    keep_only_tags = [
        dict(name='article', attrs={'class': 'main-article'}),
    ]
    remove_tags = [
        dict(attrs={'class': [
            'adv adv-middle',
            'colsx',
            'correlati',
            'social-toolbar-foot',
            'tags',
        ]}),
    ]
    remove_empty_feeds = True

    def get_feeds(self):
        soup = self.index_to_soup(self.INDEX)
        feeds = []

        for link in soup.findAll('a'):
            href = link.get('href')
            if href.endswith('.xml'):
                title = link.string
                feeds.append((title, href))

        return feeds