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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2008-2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. infobae.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class Infobae(BasicNewsRecipe):
  10.     title                 = 'Infobae.com'
  11.     __author__            = 'Darko Miletic and Sujata Raman'
  12.     description           = 'Infobae.com es el sitio de noticias con mayor actualizacion de Latinoam├⌐rica. Noticias actualizadas las 24 horas, los 365 d├¡as del a├▒o.'
  13.     publisher             = 'Infobae.com'
  14.     category              = 'news, politics, Argentina'
  15.     oldest_article        = 1
  16.     max_articles_per_feed = 100
  17.     no_stylesheets        = True
  18.     use_embedded_content  = False
  19.     language              = 'es_AR'
  20.     encoding              = 'utf8'
  21.     masthead_url          = 'http://www.infobae.com/media/img/static/logo-infobae.gif'
  22.     remove_empty_feeds    = True
  23.     extra_css             = '''
  24.                               body{font-family: Arial,Helvetica,sans-serif}
  25.                               img{display: block}
  26.                               .categoria{font-size: small; text-transform: uppercase}
  27.                             '''
  28.  
  29.     conversion_options = {
  30.                           'comment'          : description
  31.                         , 'tags'             : category
  32.                         , 'publisher'        : publisher
  33.                         , 'language'         : language
  34.                         }
  35.     
  36.     keep_only_tags    = [dict(attrs={'class':['titularnota','nota','post-title','post-entry','entry-title','entry-info','entry-content']})]
  37.     remove_tags_after = dict(attrs={'class':['interior-noticia','nota-desc','tags']})
  38.     remove_tags       = [
  39.                           dict(name=['base','meta','link','iframe','object','embed','ins'])
  40.                          ,dict(attrs={'class':['barranota','tags']})
  41.                         ]
  42.     
  43.     feeds = [
  44.               (u'Saludable' , u'http://www.infobae.com/rss/saludable.xml')
  45.              ,(u'Economia'  , u'http://www.infobae.com/rss/economia.xml' )
  46.              ,(u'En Numeros', u'http://www.infobae.com/rss/rating.xml'   )
  47.              ,(u'Finanzas'  , u'http://www.infobae.com/rss/finanzas.xml' )
  48.              ,(u'Mundo'     , u'http://www.infobae.com/rss/mundo.xml'    )
  49.              ,(u'Sociedad'  , u'http://www.infobae.com/rss/sociedad.xml' )
  50.              ,(u'Politica'  , u'http://www.infobae.com/rss/politica.xml' )
  51.              ,(u'Deportes'  , u'http://www.infobae.com/rss/deportes.xml' )
  52.             ]
  53.  
  54.     def preprocess_html(self, soup):
  55.         for item in soup.findAll(style=True):
  56.             del item['style']
  57.         for item in soup.findAll('a'):
  58.             limg = item.find('img')
  59.             if item.string is not None:
  60.                str = item.string
  61.                item.replaceWith(str)
  62.             else:
  63.                if limg:
  64.                   item.name = 'div'
  65.                   item.attrs = []
  66.                else:
  67.                    str = self.tag_to_string(item)
  68.                    item.replaceWith(str)
  69.         for item in soup.findAll('img'):
  70.             if not item.has_key('alt'):
  71.                item['alt'] = 'image'
  72.         return soup
  73.  
  74.  
  75.