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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
  5. '''
  6. lwn.net
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class LWN(BasicNewsRecipe):
  12.     title                 = u'lwn'
  13.     __author__            = 'Oliver Niesner'
  14.     description           = 'Linux Weekly News'
  15.     oldest_article        = 54
  16.     language = _('English')
  17.     max_articles_per_feed = 100
  18.     needs_subscription    = True
  19.     language = 'en'
  20.     remove_javascript      = True
  21.     simultaneous_downloads= 1
  22.     delay                 = 1
  23.     LOGIN = 'https://lwn.net/login'
  24.  
  25.     def get_browser(self):
  26.         br = BasicNewsRecipe.get_browser()
  27.         if self.username is not None and self.password is not None:
  28.             br.open(self.LOGIN)
  29.             br.select_form(name='loginform')
  30.             br['Username'] = self.username
  31.             br['Password'] = self.password
  32.             br.submit()
  33.         return br
  34.  
  35.     remove_tags = [
  36.              dict(name='td', attrs={'class':'LeftColumn'}),
  37.              dict(name='td', attrs={'class':'NavLink'}),
  38.              dict(name='div', attrs={'class':'FormattedComment'}),
  39.              dict(name='td', attrs={'class':'MCTopBanner'}),
  40.              dict(name='div', attrs={'class':'CommentBox'})
  41.                   ]
  42.  
  43.     feeds = [
  44.                (u'lwn'         , u'http://lwn.net/headlines/newrss'        ),
  45.             ]
  46.  
  47.  
  48.  
  49.     def postprocess_html(self, soup, first):
  50.         for tag in soup.findAll(name=['table', 'tr', 'td']):
  51.             tag.name = 'div'
  52.         return soup
  53.  
  54.     def print_version(self, url):
  55.         return url.replace ('rss', '?format=printable')
  56.