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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. www.financialsense.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class FinancialSense(BasicNewsRecipe):
  10.     title                 = 'Financial Sense'
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'Uncommon News & Views for the Wise Investor'
  13.     publisher             = 'Financial Sense'
  14.     category              = 'news, finances, politics, USA'
  15.     oldest_article        = 2
  16.     max_articles_per_feed = 200
  17.     no_stylesheets        = True
  18.     encoding              = 'utf8'
  19.     use_embedded_content  = False
  20.     language              = 'en'
  21.     remove_empty_feeds    = True
  22.     publication_type      = 'newsportal'
  23.     masthead_url          = 'http://www.financialsense.com/sites/default/files/logo.jpg'
  24.     extra_css             = """
  25.                                body{font-family: Arial,"Helvetica Neue",Helvetica,sans-serif }
  26.                                img{margin-bottom: 0.4em; display:block}
  27.                                h2{color: gray}
  28.                                .name{margin-right: 5em}
  29.                             """
  30.  
  31.     conversion_options = {
  32.                           'comment'   : description
  33.                         , 'tags'      : category
  34.                         , 'publisher' : publisher
  35.                         , 'language'  : language
  36.                         }
  37.  
  38.     remove_tags      =[dict(name=['meta','link','base','object','embed','iframe'])]
  39.     remove_tags_after=dict(attrs={'class':'vcard'})
  40.     keep_only_tags   =[dict(attrs={'class':['title','post-meta','content','item-title','vcard']})]
  41.     remove_attributes=['lang','type']
  42.  
  43.  
  44.     feeds = [(u'Articles', u'http://feeds.feedburner.com/fso')]
  45.  
  46.     def preprocess_html(self, soup):
  47.         for item in soup.findAll(style=True):
  48.             del item['style']
  49.         for item in soup.findAll('a'):
  50.             limg = item.find('img')
  51.             if item.string is not None:
  52.                str = item.string
  53.                item.replaceWith(str)
  54.             else:
  55.                if limg:
  56.                   item.name = 'div'
  57.                   item.attrs = []
  58.                else:
  59.                    str = self.tag_to_string(item)
  60.                    item.replaceWith(str)
  61.         for item in soup.findAll('img'):
  62.             if not item.has_key('alt'):
  63.                item['alt'] = 'image'
  64.         return soup
  65.