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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. www.elpais.com/suple/eps/
  5. '''
  6.  
  7. from calibre import strftime
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class ElPaisSemanal(BasicNewsRecipe):
  11.     title                 = 'El Pais semanal'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Revista semanal de diario El Pais'
  14.     publisher             = 'EL PAIS S.L.'
  15.     category              = 'news, politics, Spain'
  16.     no_stylesheets        = True
  17.     encoding              = 'cp1252'
  18.     use_embedded_content  = False
  19.     language              = 'es'
  20.     publication_type      = 'magazine'    
  21.     masthead_url          = 'http://www.elpais.com/im/tit_logo_int.gif'
  22.     index                 = 'http://www.elpais.com/suple/eps/'
  23.     extra_css             = ' p{text-align: justify} body{ text-align: left; font-family: Georgia,"Times New Roman",Times,serif } h2{font-family: Arial,Helvetica,sans-serif} img{margin-bottom: 0.4em} '
  24.  
  25.     conversion_options = {
  26.                           'comment'      : description
  27.                         , 'tags'         : category
  28.                         , 'publisher'    : publisher
  29.                         , 'language'     : language
  30.                         }
  31.  
  32.     keep_only_tags=[dict(attrs={'class':['cabecera_noticia','contenido_noticia']})]
  33.     remove_attributes=['width','height']
  34.     remove_tags=[dict(name='link')]
  35.  
  36.     def parse_index(self):
  37.         articles = []
  38.         soup = self.index_to_soup(self.index)
  39.         for item in soup.findAll('a',attrs={'class':['g19i003','g17r003','g17i003']}):
  40.             description = ''
  41.             title_prefix = ''
  42.             feed_link = item
  43.             if item.has_key('href'):
  44.                 url   = 'http://www.elpais.com' + item['href'].rpartition('/')[0]
  45.                 title = title_prefix + self.tag_to_string(feed_link)
  46.                 date  = strftime(self.timefmt)
  47.                 articles.append({
  48.                                   'title'      :title
  49.                                  ,'date'       :date
  50.                                  ,'url'        :url
  51.                                  ,'description':description
  52.                                 })
  53.         return [(soup.head.title.string, articles)]
  54.  
  55.     def print_version(self, url):
  56.         return url + '?print=1'
  57.