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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. vesti.krstarica.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class Krstarica_en(BasicNewsRecipe):
  12.     title                 = 'Krstarica - news in english'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'News from Serbia and world'    
  15.     publisher             = 'Krstarica'
  16.     category              = 'news, politics, Serbia'
  17.     oldest_article        = 1
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     use_embedded_content  = False
  21.     remove_javascript     = True
  22.     encoding              = 'utf-8'
  23.     language = 'en'
  24.  
  25.     
  26.     html2lrf_options = [
  27.                           '--comment', description
  28.                         , '--category', category
  29.                         , '--publisher', publisher
  30.                         ]
  31.     
  32.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em}"' 
  33.         
  34.     feeds          = [
  35.                         (u'Daily news', u'http://vesti.krstarica.com/index.php?rss=1&rubrika=aktuelno&lang=1'     )
  36.                        ,(u'Serbia'    , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=scg&lang=1'          )
  37.                        ,(u'Politics'  , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=politika&lang=1'     )
  38.                        ,(u'Economy'   , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=ekonomija&lang=1'    )
  39.                        ,(u'Culture'   , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=kultura&lang=1'      )
  40.                        ,(u'Sports'    , u'http://vesti.krstarica.com/index.php?rss=1&rubrika=sport&lang=1'        )
  41.                      ]
  42.  
  43.     def preprocess_html(self, soup):
  44.         mtag = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
  45.         soup.head.insert(0,mtag)
  46.         titletag = soup.find('h4')
  47.         if titletag:
  48.            realtag = titletag.parent.parent
  49.            realtag.extract()
  50.            for item in soup.findAll(['table','center']):
  51.                item.extract()
  52.            soup.body.insert(1,realtag)            
  53.            realtag.name = 'div'
  54.         for item in soup.findAll(style=True):
  55.             del item['style']
  56.         for item in soup.findAll(align=True):
  57.             del item['align']
  58.         return soup
  59.