home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_280 / 20minutos.recipe < prev    next >
Text File  |  2011-09-09  |  3KB  |  69 lines

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. www.20minutos.es
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class t20Minutos(BasicNewsRecipe):
  10.     title                 = '20 Minutos'
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'Diario de informacion general y local mas leido de Espania, noticias de ultima hora de Espania, el mundo, local, deportes, noticias curiosas y mas'
  13.     publisher             = '20 Minutos Online SL'
  14.     category              = 'news, politics, Spain'
  15.     oldest_article        = 2
  16.     max_articles_per_feed = 200
  17.     no_stylesheets        = True
  18.     encoding              = 'utf8'
  19.     use_embedded_content  = True
  20.     language              = 'es'
  21.     remove_empty_feeds    = True
  22.     publication_type      = 'newspaper'
  23.     masthead_url          = 'http://estaticos.20minutos.es/css4/img/ui/logo-301x54.png'
  24.     extra_css             = """
  25.                                body{font-family: Arial,Helvetica,sans-serif }
  26.                                img{margin-bottom: 0.4em; display:block}
  27.                             """
  28.  
  29.     conversion_options = {
  30.                           'comment'   : description
  31.                         , 'tags'      : category
  32.                         , 'publisher' : publisher
  33.                         , 'language'  : language
  34.                         }
  35.  
  36.     remove_tags = [dict(attrs={'class':'mf-viral'})]
  37.     remove_attributes=['border']
  38.  
  39.     feeds = [
  40.               (u'Principal'      , u'http://20minutos.feedsportal.com/c/32489/f/478284/index.rss')
  41.              ,(u'Cine'           , u'http://20minutos.feedsportal.com/c/32489/f/478285/index.rss')
  42.              ,(u'Internacional'  , u'http://20minutos.feedsportal.com/c/32489/f/492689/index.rss')
  43.              ,(u'Deportes'       , u'http://20minutos.feedsportal.com/c/32489/f/478286/index.rss')
  44.              ,(u'Nacional'       , u'http://20minutos.feedsportal.com/c/32489/f/492688/index.rss')
  45.              ,(u'Economia'       , u'http://20minutos.feedsportal.com/c/32489/f/492690/index.rss')
  46.              ,(u'Tecnologia'     , u'http://20minutos.feedsportal.com/c/32489/f/478292/index.rss')
  47.             ]
  48.  
  49.     def preprocess_html(self, soup):
  50.         for item in soup.findAll(style=True):
  51.             del item['style']
  52.         for item in soup.findAll('a'):
  53.             limg = item.find('img')
  54.             if item.string is not None:
  55.                str = item.string
  56.                item.replaceWith(str)
  57.             else:
  58.                if limg:
  59.                   item.name = 'div'
  60.                   item.attrs = []
  61.                else:
  62.                    str = self.tag_to_string(item)
  63.                    item.replaceWith(str)
  64.         for item in soup.findAll('img'):
  65.             if not item.has_key('alt'):
  66.                item['alt'] = 'image'
  67.         return soup
  68.  
  69.