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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __author__ = '2010, Gustavo Azambuja <hola at gazambuja.com>'
  5. '''
  6. http://www.elpais.com.uy/
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class General(BasicNewsRecipe):
  12.     title                 = 'El Pais - Uruguay'
  13.     __author__            = 'Gustavo Azambuja'
  14.     description           = 'Noticias de Uruguay y el resto del mundo'
  15.     publisher             = 'EL PAIS S.A.'
  16.     category              = 'news, politics, Uruguay'
  17.     language       = 'es_UY'
  18.     timefmt        = '[%a, %d %b, %Y]'
  19.     use_embedded_content  = False
  20.     recursion             = 2
  21.     encoding = 'iso-8859-1'
  22.     masthead_url          = 'http://www.elpais.com.uy/Images/09/cabezal/logo_PDEP.png'
  23.     publication_type      = 'newspaper'
  24.     remove_javascript = True
  25.     no_stylesheets = True
  26.  
  27.     oldest_article        = 2
  28.     max_articles_per_feed = 200
  29.     keep_only_tags = [
  30.                       dict(name='h1'),
  31.                       dict(name='div', attrs={'id':'Contenido'})
  32.                       ]
  33.  
  34.     conversion_options = {
  35.                           'comment'          : description
  36.                         , 'tags'             : category
  37.                         , 'publisher'        : publisher
  38.                         , 'language'         : language
  39.                         }
  40.     remove_tags = [
  41.                  dict(name='div', attrs={'class':['date_text', 'comments', 'form_section', 'share_it']}),
  42.                  dict(name='div', attrs={'id':['relatedPosts', 'spacer', 'banner_izquierda', 'right_container']}),
  43.                  dict(name='p', attrs={'class':'FacebookLikeButton'}),
  44.                  dict(name=['object','form']),
  45.                  dict(name=['object','table']) ]
  46.  
  47.     extra_css = '''
  48.                 h1{font-family:Geneva, Arial, Helvetica, sans-serif;color:#154B7A;}
  49.                 h3{font-size: 14px;color:#999999; font-family:Geneva, Arial, Helvetica, sans-serif;font-weight: bold;}
  50.                 h2{color:#666666; font-family:Geneva, Arial, Helvetica, sans-serif;font-size:small;}
  51.                 p {font-family:Arial,Helvetica,sans-serif;}
  52.                 body{font-family: Verdana,Arial,Helvetica,sans-serif }
  53.                 img{margin-bottom: 0.4em; display:block;}
  54.                 '''
  55.     feeds = [
  56.            (u'Ultimo Momento', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=umomento'),
  57.            (u'Editorial', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=editorial'),
  58.            (u'Nacional', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=nacional'),
  59.            (u'Internacional', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=internacional'),
  60.            (u'Espectaculos', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=espectaculos'),
  61.            (u'Deportes', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=deportes'),
  62.            (u'Ciudades', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=ciudades'),
  63.            (u'Economia', u'http://www.elpais.com.uy/formatos/rss/index.asp?seccion=economia')
  64.         ]
  65.  
  66.     def get_cover_url(self):
  67.         cover_url = None
  68.         index = 'http://www.elpais.com.uy'
  69.         soup = self.index_to_soup(index)
  70.         link_item = soup.find('div',attrs={'class':'boxmedio box257'})
  71.         print link_item
  72.         if link_item:
  73.             cover_url = 'http://www.elpais.com.uy'+link_item.img['src']
  74.         return cover_url
  75.  
  76.     def preprocess_html(self, soup):
  77.         for item in soup.findAll(style=True):
  78.             del item['style']
  79.         return soup
  80.  
  81.