~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_elperiodico_spanish.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090730124941-kviipg9ypwgppulc
Tags: upstream-0.6.3+dfsg
Import upstream version 0.6.3+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env  python
 
2
# -*- coding: utf-8 -*-
 
3
 
 
4
__license__   = 'GPL v3'
 
5
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
 
6
'''
 
7
elperiodico.com
 
8
'''
 
9
 
 
10
from calibre.web.feeds.news import BasicNewsRecipe
 
11
from calibre.ebooks.BeautifulSoup import Tag
 
12
 
 
13
class ElPeriodico_esp(BasicNewsRecipe):
 
14
    title                 = 'El Periodico de Catalunya'
 
15
    __author__            = 'Darko Miletic'
 
16
    description           = 'Noticias desde Catalunya'
 
17
    publisher             = 'elperiodico.com'
 
18
    category              = 'news, politics, Spain, Catalunya'
 
19
    oldest_article        = 2
 
20
    max_articles_per_feed = 100
 
21
    no_stylesheets        = True
 
22
    use_embedded_content  = False
 
23
    delay                 = 1
 
24
    encoding              = 'cp1252'
 
25
    language              = _('Spanish')
 
26
 
 
27
    html2lrf_options = [
 
28
                          '--comment'  , description
 
29
                        , '--category' , category
 
30
                        , '--publisher', publisher
 
31
                        ]
 
32
 
 
33
    html2epub_options  = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
 
34
 
 
35
    feeds              = [(u"Toda la edición", u'http://www.elperiodico.com/rss.asp?id=46')]
 
36
 
 
37
 
 
38
    keep_only_tags = [dict(name='div', attrs={'id':'noticia'})]
 
39
 
 
40
    remove_tags        = [
 
41
                              dict(name=['object','link','script'])
 
42
                             ,dict(name='ul',attrs={'class':'herramientasDeNoticia'})
 
43
                             ,dict(name='div', attrs={'id':'inferiores'})
 
44
                         ]
 
45
 
 
46
    def print_version(self, url):
 
47
        return url.replace('/default.asp?','/print.asp?')
 
48
 
 
49
    def preprocess_html(self, soup):
 
50
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
 
51
        soup.head.insert(0,mcharset)
 
52
        for item in soup.findAll(style=True):
 
53
            del item['style']
 
54
        return soup
 
55