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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010-2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. perfil.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class Perfil(BasicNewsRecipe):
  10.     title                 = 'Perfil'
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'Noticias de Argentina y el resto del mundo'
  13.     publisher             = 'perfil.com'
  14.     category              = 'news, politics, Argentina'
  15.     oldest_article        = 2
  16.     max_articles_per_feed = 200
  17.     no_stylesheets        = True
  18.     encoding              = 'cp1252'
  19.     use_embedded_content  = False
  20.     language              = 'es_AR'
  21.     remove_empty_feeds    = True
  22.     masthead_url          = 'http://www.perfil.com/export/sites/diarioperfil/arte/10/logo_perfilcom_mm.gif'
  23.     extra_css             = """
  24.                                 body{font-family: Arial,Helvetica,sans-serif }
  25.                                 .seccion{border-bottom: 1px dotted #666666; text-transform: uppercase; font-size: x-large}
  26.                                 .foto1 h1{font-size: x-small}
  27.                                 h1{font-family: Georgia,"Times New Roman",serif}
  28.                                 img{margin-bottom: 0.4em}
  29.                                 .hora{font-size: x-small; color: red}
  30.                             """
  31.  
  32.     conversion_options = {
  33.                           'comment'   : description
  34.                         , 'tags'      : category
  35.                         , 'publisher' : publisher
  36.                         , 'language'  : language
  37.                         }
  38.  
  39.     remove_tags   = [
  40.                       dict(name=['iframe','embed','object','base','meta','link'])
  41.                      ,dict(name='a', attrs={'href':'#comentarios'})
  42.                      ,dict(name='div', attrs={'class':'foto3'})
  43.                      ,dict(name='img', attrs={'alt':['ampliar','Ampliar']})
  44.                     ]
  45.     keep_only_tags=[dict(attrs={'class':['articulo','cuerpoSuperior']})]
  46.     remove_attributes=['onload','lang','width','height','border']
  47.  
  48.     feeds = [
  49.               (u'Ultimo momento' , u'http://www.perfil.com/rss/ultimomomento.xml')
  50.              ,(u'Politica'       , u'http://www.perfil.com/rss/politica.xml'     )
  51.              ,(u'Policia'        , u'http://www.perfil.com/rss/policia.xml'      )
  52.              ,(u'Internacionales', u'http://www.perfil.com/rss/internacional.xml')
  53.              ,(u'Economia'       , u'http://www.perfil.com/rss/economia.xml'     )
  54.              ,(u'Deportes'       , u'http://www.perfil.com/rss/deportes.xml'     )
  55.              ,(u'Opinion'        , u'http://www.perfil.com/rss/columnistas.xml'  )
  56.              ,(u'Sociedad'       , u'http://www.perfil.com/rss/sociedad.xml'     )
  57.              ,(u'Cultura'        , u'http://www.perfil.com/rss/cultura.xml'      )
  58.              ,(u'Espectaculos'   , u'http://www.perfil.com/rss/espectaculos.xml' )
  59.              ,(u'Ciencia'        , u'http://www.perfil.com/rss/ciencia.xml'      )
  60.              ,(u'Salud'          , u'http://www.perfil.com/rss/salud.xml'        )
  61.              ,(u'Tecnologia'     , u'http://www.perfil.com/rss/tecnologia.xml'   )
  62.             ]
  63.  
  64.     def get_article_url(self, article):
  65.         return article.get('guid',  None)
  66.             
  67.     def preprocess_html(self, soup):
  68.         for item in soup.findAll(style=True):
  69.             del item['style']
  70.         for item in soup.findAll('a'):
  71.             limg = item.find('img')
  72.             if item.string is not None:
  73.                str = item.string
  74.                item.replaceWith(str)
  75.             else:
  76.                if limg:
  77.                   item.name = 'div'
  78.                   item.attrs = []
  79.                else:
  80.                    str = self.tag_to_string(item)
  81.                    item.replaceWith(str)
  82.         for item in soup.findAll('img'):
  83.             if not item.has_key('alt'):
  84.                item['alt'] = 'image'
  85.         return soup
  86.