home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3754 < prev    next >
Encoding:
Text File  |  2009-12-15  |  2.2 KB  |  64 lines

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. ft.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class FinancialTimes(BasicNewsRecipe):
  12.     title                 = u'Financial Times'
  13.     __author__            = 'Darko Miletic and Sujata Raman'
  14.     description           = 'Financial world news'
  15.     oldest_article        = 2
  16.     language = 'en'
  17.  
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     use_embedded_content  = False
  21.     needs_subscription    = True
  22.     simultaneous_downloads= 1
  23.     delay                 = 1
  24.  
  25.     LOGIN = 'https://registration.ft.com/registration/barrier/login'
  26.  
  27.     def get_browser(self):
  28.         br = BasicNewsRecipe.get_browser()
  29.         if self.username is not None and self.password is not None:
  30.             br.open(self.LOGIN)
  31.             br.select_form(name='loginForm')
  32.             br['username'] = self.username
  33.             br['password'] = self.password
  34.             br.submit()
  35.         return br
  36.  
  37.     keep_only_tags    = [ dict(name='div', attrs={'id':'cont'}) ]
  38.     remove_tags_after = dict(name='p', attrs={'class':'copyright'})
  39.     remove_tags = [
  40.                      dict(name='div', attrs={'id':'floating-con'})
  41.                   ]
  42.  
  43.     extra_css = '''
  44.                 body{font-family:Arial,Helvetica,sans-serif;}
  45.                 h2(font-size:large;}
  46.                 .ft-story-header(font-size:xx-small;}
  47.                 .ft-story-body(font-size:small;}
  48.                 a{color:#003399;}
  49.                 .container{font-size:x-small;}
  50.                 h3{font-size:x-small;color:#003399;}
  51.                 '''
  52.     feeds = [
  53.                (u'UK'         , u'http://www.ft.com/rss/home/uk'        )
  54.               ,(u'US'         , u'http://www.ft.com/rss/home/us'        )
  55.               ,(u'Asia'       , u'http://www.ft.com/rss/home/asia'      )
  56.               ,(u'Middle East', u'http://www.ft.com/rss/home/middleeast')
  57.             ]
  58.  
  59.     def preprocess_html(self, soup):
  60.         content_type = soup.find('meta', {'http-equiv':'Content-Type'})
  61.         if content_type:
  62.             content_type['content'] = 'text/html; charset=utf-8'
  63.         return soup
  64.