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

  1. #!/usr/bin/env  python
  2. # -*- coding: utf-8 -*-
  3.  
  4. __license__   = 'GPL v3'
  5. __copyright__ = '2010, Francisco Javier Nieto <frjanibo at gmail.com>'
  6. '''
  7. www.hoy.es
  8. '''
  9.  
  10. from calibre.web.feeds.news import BasicNewsRecipe
  11. from calibre.ebooks.BeautifulSoup import Tag
  12.  
  13. class Hoy(BasicNewsRecipe):
  14.     title                 = 'HOY'
  15.     __author__            = 'Fco Javier Nieto'
  16.     description           = u'Noticias desde Extremadura'
  17.     publisher             = 'HOY'
  18.     category              = 'news, politics, Spain, Extremadura'
  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 = 'es'
  26.  
  27.     feeds              = [
  28.                             (u'Portada'         , u'http://www.hoy.es/portada.xml'   ),
  29.                             (u'Regional'        , u'http://www.hoy.es/rss/feeds/regional.xml'   ),
  30.                             (u'Prov de Badajoz' , u'http://www.hoy.es/rss/feeds/prov_badajoz.xml'   ),
  31.                             (u'Prov de Caceres' , u'http://www.hoy.es/rss/feeds/prov_caceres.xml'   ),
  32.                             (u'Badajoz'         , u'http://www.hoy.es/rss/feeds/badajoz.xml'      ),
  33.                             (u'Caceres'         , u'http://www.hoy.es/rss/feeds/caceres.xml'      ),
  34.                             (u'Merida'          , u'http://www.hoy.es/rss/feeds/merida.xml'      ),
  35.                             (u'Opinion'         , u'http://www.hoy.es/rss/feeds/opinion.xml'      ),
  36.                             (u'Nacional'        , u'http://www.hoy.es/rss/feeds/nacional.xml'      ),
  37.                             (u'Internacional'   , u'http://www.hoy.es/rss/feeds/internacional.xml'      ),
  38.                             (u'Economia'        , u'http://www.hoy.es/rss/feeds/economia.xml'      ),
  39.                             (u'Deportes'        , u'http://www.hoy.es/rss/feeds/deportes.xml'      ),
  40.                             (u'Sociedad'        , u'http://www.hoy.es/rss/feeds/sociedad.xml'      ),
  41.                             (u'Cultura'         , u'http://www.hoy.es/rss/feeds/cultura.xml'      ),
  42.                             (u'Television'      , u'http://www.hoy.es/rss/feeds/television.xml'      ),
  43.                             (u'contraportada'   , u'http://www.hoy.es/rss/feeds/contraportada.xml'      )
  44.                          ]
  45.  
  46.  
  47.     keep_only_tags = [
  48.                        dict(name='h1', attrs={'class':['headline']}),
  49.                        dict(name='h2', attrs={'class':['subhead']}),
  50.                        dict(name='div', attrs={'class':['text']})
  51.                      ]
  52.  
  53.     remove_tags        = [
  54.                              dict(name=['object','link','script'])
  55.                             ,dict(name='div', attrs={'class':['colC_articulo','peu']})
  56.                          ]
  57.  
  58.     remove_tags_after = [dict(name='div', attrs={'class':'text'})]
  59.  
  60.     extra_css = '.headline {font: sans-serif 2em;}\n.subhead,h2{font: sans-serif 1.5em\n'
  61.  
  62.     def preprocess_html(self, soup):
  63.         soup.html['dir' ] = self.direction
  64.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  65.         soup.head.insert(0,mcharset)
  66.         for item in soup.findAll(style=True):
  67.             del item['style']
  68.         return soup
  69.  
  70.