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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.tijd.be
  7. '''
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9. from calibre.ebooks.BeautifulSoup import Tag
  10.  
  11. class DeTijd(BasicNewsRecipe):
  12.     title                 = 'De Tijd'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'News from Belgium in Dutch'
  15.     publisher             = 'De Tijd'
  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':'lcol'})]
  36.     remove_tags    = [
  37.                          dict(name=['embed','object'])
  38.                        , dict (name='div',attrs={'id':'art_reactwrap'})
  39.                      ]
  40.     remove_tags_after  = dict(name='div', attrs={'id':'art_author'})
  41.  
  42.     feeds = [
  43.               (u'Volledig nieuwsaanbod', u'http://www.tijd.be/rss/nieuws.xml'        )
  44.              ,(u'Markten'              , u'http://www.tijd.be/rss/markten.xml'       )
  45.              ,(u'Ondernemingen'        , u'http://www.tijd.be/rss/ondernemingen.xml' )
  46.              ,(u'Chemie-Farma'         , u'http://www.tijd.be/rss/chemie_farma.xml'  )
  47.              ,(u'Consumptie'           , u'http://www.tijd.be/rss/consumptie.xml'    )
  48.              ,(u'Diensten'             , u'http://www.tijd.be/rss/diensten.xml'      )
  49.              ,(u'Energie'              , u'http://www.tijd.be/rss/energie.xml'       )
  50.              ,(u'Financen'             , u'http://www.tijd.be/rss/financien.xml'     )
  51.              ,(u'Industrie'            , u'http://www.tijd.be/rss/industrie.xml'     )
  52.              ,(u'Media'                , u'http://www.tijd.be/rss/media_telecom.xml' )
  53.              ,(u'Technologie'          , u'http://www.tijd.be/rss/technologie.xml'   )
  54.              ,(u'Economie & Financien' , u'http://www.tijd.be/rss/economie.xml'      )
  55.              ,(u'Binnenland'           , u'http://www.tijd.be/rss/binnenland.xml'    )
  56.              ,(u'Buitenland'           , u'http://www.tijd.be/rss/buitenland.xml'    )
  57.              ,(u'De wijde wereld'      , u'http://www.tijd.be/rss/cultuur.xml'       )
  58.             ]
  59.  
  60.     def preprocess_html(self, soup):
  61.         del soup.body['onload']
  62.         for item in soup.findAll(style=True):
  63.             del item['style']
  64.         soup.html['lang']     = self.lang
  65.         soup.html['dir' ]     = self.direction
  66.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  67.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  68.         soup.head.insert(0,mlang)
  69.         soup.head.insert(1,mcharset)
  70.         return soup
  71.  
  72.