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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __author__ = '2010, Gustavo Azambuja <hola at gazambuja.com>'
  5. '''
  6. observa.com.uy
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class Noticias(BasicNewsRecipe):
  12.     title                 = 'Observa Digital'
  13.     __author__ = '2010, Gustavo Azambuja <hola at gazambuja.com>'
  14.     description           = 'Noticias desde Uruguay'
  15.     language       = 'es_UY'
  16.     timefmt        = '[%a, %d %b, %Y]'
  17.     use_embedded_content  = False
  18.     recursion             = 5
  19.     encoding = 'utf8'
  20.     remove_javascript = True
  21.     no_stylesheets = True
  22.  
  23.     oldest_article        = 2
  24.     max_articles_per_feed = 100
  25.     keep_only_tags = [dict(id=['contenido'])]
  26.     remove_tags = [
  27.              dict(name='div', attrs={'id':'contenedorVinculadas'}),
  28.              dict(name='p', attrs={'id':'nota_firma'}),
  29.              dict(name=['object','link'])
  30.                   ]
  31.  
  32.     remove_attributes = ['width','height', 'style', 'font', 'color']
  33.  
  34.     extra_css = '''
  35.                 h1{font-family:Geneva, Arial, Helvetica, sans-serif;color:#154B7A;}
  36.                 h3{font-size: 14px;color:#999999; font-family:Geneva, Arial, Helvetica, sans-serif;font-weight: bold;}
  37.                 h2{color:#666666; font-family:Geneva, Arial, Helvetica, sans-serif;font-size:small;}
  38.                 p {font-family:Arial,Helvetica,sans-serif;}
  39.                 '''
  40.     feeds = [
  41.            (u'Actualidad', u'http://www.observa.com.uy/RSS/actualidad.xml'),
  42.            (u'Deportes', u'http://www.observa.com.uy/RSS/deportes.xml'),
  43.            (u'Vida', u'http://www.observa.com.uy/RSS/vida.xml'),
  44.            (u'Ciencia y Tecnologia', u'http://www.observa.com.uy/RSS/ciencia.xml')
  45.         ]
  46.  
  47.     def get_cover_url(self):
  48.         cover_url = None
  49.         index = 'http://www.elobservador.com.uy/elobservador/nav_portada.asp?suplemento=dia'
  50.         soup = self.index_to_soup(index)
  51.         link_item = soup.find('img',attrs={'usemap':'#mapeo_imagenes'})
  52.         if link_item:
  53.             cover_url = 'http://www.elobservador.com.uy'+link_item['src'].strip()
  54.  
  55.         print cover_url
  56.  
  57.         return cover_url
  58.  
  59.  
  60.     def preprocess_html(self, soup):
  61.         for item in soup.findAll(style=True):
  62.             del item['style']
  63.         return soup
  64.