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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.livemint.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class Edgesingapore(BasicNewsRecipe):
  12.     title                 = 'The Edge Singapore'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'Financial news from Singapore'
  15.     publisher             = 'The Edge Singapore'
  16.     category              = 'news, finances, singapore'
  17.     language = 'en'
  18.  
  19.     lang                  = 'en_SG'
  20.     oldest_article        = 15
  21.     max_articles_per_feed = 100
  22.     no_stylesheets        = True
  23.     encoding              = 'utf-8'
  24.     use_embedded_content  = False
  25.     extra_css             = ' .contentheading{font-size: x-large} .small{font-size: small} .createdate{font-size: small; font-weight: bold} '
  26.  
  27.  
  28.     conversion_options = {
  29.                           'comment'          : description
  30.                         , 'tags'             : category
  31.                         , 'publisher'        : publisher
  32.                         , 'author'           : publisher
  33.                         , 'language'         : lang
  34.                         , 'pretty_print'     : True
  35.                         , 'linearize_tables' : True
  36.                         }
  37.  
  38.  
  39.     remove_tags = [
  40.                     dict(name=['object','link','embed','form','iframe'])
  41.                    ,dict(name='div',attrs={'id':'toolbar-article'})
  42.                    ,dict(name='div',attrs={'class':'backtotop'})
  43.                    ,dict(name='img',attrs={'alt':'Print'})
  44.                   ]
  45.  
  46.     remove_tags_after = dict(name='div',attrs={'class':'backtotop'})
  47.  
  48.     feeds = [(u'Articles', u'http://feeds.feedburner.com/edgesg')]
  49.  
  50.     def print_version(self, url):
  51.         return url + '?tmpl=component&print=1'
  52.  
  53.     def preprocess_html(self, soup):
  54.         attribs = [  'style','font','valign'
  55.                     ,'colspan','width','height'
  56.                     ,'rowspan','summary','align'
  57.                     ,'cellspacing','cellpadding'
  58.                     ,'frames','rules','border'
  59.                   ]
  60.         for item in soup.body.findAll(name=['table','td','tr','th','caption','thead','tfoot','tbody','colgroup','col']):
  61.             item.name = 'div'
  62.             for attrib in attribs:
  63.                 if item.has_key(attrib):
  64.                    del item[attrib]
  65.         return self.adeify_images(soup)
  66.