home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_4073 < prev    next >
Encoding:
Text File  |  2009-10-14  |  2.1 KB  |  58 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. economictimes.indiatimes.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class TheEconomicTimes(BasicNewsRecipe):
  13.     title                  = 'The Economic Times India'
  14.     __author__             = 'Darko Miletic'
  15.     description            = 'Financial news from India'
  16.     publisher              = 'economictimes.indiatimes.com'
  17.     category               = 'news, finances, politics, India'
  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-IN'
  25.     language = 'en_IN'
  26.  
  27.  
  28.     html2lrf_options = [
  29.                           '--comment', description
  30.                         , '--category', category
  31.                         , '--publisher', publisher
  32.                         , '--ignore-tables'
  33.                         ]
  34.  
  35.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True'
  36.  
  37.     feeds          = [(u'All articles', u'http://economictimes.indiatimes.com/rssfeedsdefault.cms')]
  38.  
  39.     def print_version(self, url):
  40.         rest, sep, art = url.rpartition('/articleshow/')
  41.         return 'http://economictimes.indiatimes.com/articleshow/' + art + '?prtpage=1'
  42.  
  43.     def get_article_url(self, article):
  44.         rurl = article.get('link',  None)
  45.         if (rurl.find('/quickieslist/') > 0) or (rurl.find('/quickiearticleshow/') > 0):
  46.            return None
  47.         return rurl
  48.  
  49.     def preprocess_html(self, soup):
  50.         soup.html['xml:lang'] = self.lang
  51.         soup.html['lang']     = self.lang
  52.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  53.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  54.         soup.head.insert(0,mlang)
  55.         soup.head.insert(1,mcharset)
  56.         return self.adeify_images(soup)
  57.  
  58.