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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.accountancyage.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class AccountancyAge(BasicNewsRecipe):
  13.     title                  = 'Accountancy Age'
  14.     __author__             = 'Darko Miletic'
  15.     description            = 'business news'
  16.     publisher              = 'accountancyage.com'
  17.     category               = 'news, politics, finances'
  18.     oldest_article         = 2
  19.     max_articles_per_feed  = 100
  20.     no_stylesheets         = True
  21.     use_embedded_content   = False
  22.     simultaneous_downloads = 1
  23.     encoding               = 'utf-8'
  24.     lang                   = 'en'
  25.     language = 'en'
  26.  
  27.  
  28.     html2lrf_options = [
  29.                           '--comment', description
  30.                         , '--category', category
  31.                         , '--publisher', publisher
  32.                         ]
  33.  
  34.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
  35.  
  36.     keep_only_tags      = [dict(name='div', attrs={'class':'bodycol'})]
  37.     remove_tags         = [dict(name=['embed','object'])]
  38.     remove_tags_after   = dict(name='div', attrs={'id':'permalink'})
  39.     remove_tags_before  = dict(name='div', attrs={'class':'gap6'})
  40.  
  41.     feeds          = [(u'All News', u'http://feeds.accountancyage.com/rss/latest/accountancyage/all')]
  42.  
  43.     def print_version(self, url):
  44.         rest, sep, miss = url.rpartition('/')
  45.         rr, ssep, artid = rest.rpartition('/')
  46.         return u'http://www.accountancyage.com/articles/print/' + artid
  47.  
  48.     def get_article_url(self, article):
  49.         return article.get('guid',  None)
  50.  
  51.     def preprocess_html(self, soup):
  52.         soup.html['xml:lang'] = self.lang
  53.         soup.html['lang']     = self.lang
  54.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  55.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")])
  56.         soup.head.insert(0,mlang)
  57.         soup.head.insert(1,mcharset)
  58.         return self.adeify_images(soup)
  59.  
  60.