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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.tiempo.hn
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class ElTiempoHn(BasicNewsRecipe):
  13.     title                 = 'El Tiempo - Honduras'
  14.     __author__            = 'Darko Miletic'
  15.     description           = 'Noticias de Honduras y mundo'
  16.     publisher             = 'El Tiempo'
  17.     category              = 'news, politics, Honduras'
  18.     oldest_article        = 2
  19.     max_articles_per_feed = 100
  20.     use_embedded_content  = False
  21.     no_stylesheets        = True
  22.     remove_javascript     = True
  23.     encoding              = 'utf-8'
  24.     language = 'es_HN'
  25.  
  26.     lang                  = 'es-HN'
  27.     direction             = 'ltr'
  28.  
  29.     html2lrf_options = [
  30.                           '--comment', description
  31.                         , '--category', category
  32.                         , '--publisher', publisher
  33.                         , '--ignore-tables'
  34.                         ]
  35.  
  36.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True\npretty_print=True\noverride_css=" p {text-indent: 0cm; margin-top: 0em; margin-bottom: 0.5em} img {text-indent: 0cm; margin-top: 0em; margin-bottom: 0.5em}"'
  37.  
  38.     remove_tags = [dict(name=['form','object','embed','base'])]
  39.  
  40.     keep_only_tags = [dict(name='td' , attrs={'id':'mainbodycont'})]
  41.  
  42.     feeds = [(u'Noticias', u'http://www.tiempo.hn/index.php?format=feed&type=rss')]
  43.  
  44.     def preprocess_html(self, soup):
  45.         soup.html['lang'] = self.lang
  46.         soup.html['dir' ] = self.direction
  47.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  48.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  49.         soup.head.insert(0,mlang)
  50.         soup.head.insert(1,mcharset)
  51.         for item in soup.findAll(style=True):
  52.             del item['style']
  53.         return self.adeify_images(soup)
  54.