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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.gva.be
  7. '''
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9. from calibre.ebooks.BeautifulSoup import Tag
  10.  
  11. class GazetvanAntwerpen(BasicNewsRecipe):
  12.     title                 = 'Gazet van Antwerpen'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'News from Belgium in Dutch'
  15.     publisher             = 'Gazet van Antwerpen'
  16.     category              = 'news, politics, Belgium'
  17.     oldest_article        = 2
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     use_embedded_content  = False
  21.     encoding              = 'utf-8'
  22.     language = 'nl_BE'
  23.  
  24.     lang                  = 'nl-BE'
  25.     direction             = 'ltr'
  26.  
  27.     html2lrf_options = [
  28.                           '--comment'  , description
  29.                         , '--category' , category
  30.                         , '--publisher', publisher
  31.                         ]
  32.  
  33.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0cm; margin-top: 0em; margin-bottom: 0.5em} "'
  34.  
  35.     keep_only_tags = [dict(name='div', attrs={'id':'article'})]
  36.     remove_tags    = [
  37.                          dict(name=['embed','object'])
  38.                        , dict (name='div',attrs={'class':['note NotePortrait','note']})
  39.                      ]
  40.     remove_tags_after  = dict(name='span', attrs={'class':'author'})
  41.  
  42.     feeds = [
  43.               (u'Binnenland'            , u'http://www.gva.be/syndicationservices/artfeedservice.svc/rss/mostrecent/binnenland'    )
  44.              ,(u'Buitenland'            , u'http://www.gva.be/syndicationservices/artfeedservice.svc/rss/mostrecent/buitenland'    )
  45.              ,(u'Stad & Regio'          , u'http://www.gva.be/syndicationservices/artfeedservice.svc/rss/mostrecent/stadenregio'   )
  46.              ,(u'Economie'              , u'http://www.gva.be/syndicationservices/artfeedservice.svc/rss/mostrecent/economie'      )
  47.              ,(u'Media & Cultur'        , u'http://www.gva.be/syndicationservices/artfeedservice.svc/rss/mostrecent/mediaencultuur')
  48.              ,(u'Wetenschap'            , u'http://www.gva.be/syndicationservices/artfeedservice.svc/rss/mostrecent/wetenschap'    )
  49.              ,(u'Sport'                 , u'http://www.gva.be/syndicationservices/artfeedservice.svc/rss/mostrecent/sport'         )
  50.             ]
  51.  
  52.     def preprocess_html(self, soup):
  53.         del soup.body['onload']
  54.         for item in soup.findAll(style=True):
  55.             del item['style']
  56.         soup.html['lang']     = self.lang
  57.         soup.html['dir' ]     = self.direction
  58.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  59.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  60.         soup.head.insert(0,mlang)
  61.         soup.head.insert(1,mcharset)
  62.         return soup
  63.  
  64.