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

  1. #!/usr/bin/env python
  2. # vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
  3. from __future__ import with_statement
  4.  
  5. __license__   = 'GPL v3'
  6. __copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
  7. __docformat__ = 'restructuredtext en'
  8.  
  9. import re
  10. from calibre.web.feeds.news import BasicNewsRecipe
  11.  
  12. class Tweakers(BasicNewsRecipe):
  13.      title          = u'Tweakers.net'
  14.      __author__     = 'Kovid Goyal'
  15.      language       = 'nl'
  16.      oldest_article = 4
  17.      max_articles_per_feed = 40
  18.  
  19.      keep_only_tags = [dict(name='div', attrs={'class':'columnwrapper news'})]
  20.  
  21.      remove_tags    = [dict(name='div', attrs={'class':'reacties'}),
  22.                         {'id' : ['utracker']},
  23.                         {'class' : ['sidebar']},
  24.                         {'class' : re.compile('nextPrevious')},
  25.                       ]
  26.      no_stylesheets=True
  27.  
  28.      feeds          = [(u'Tweakers.net', u'http://tweakers.net/feeds/nieuws.xml')]
  29.  
  30.      def preprocess_html(self, soup):
  31.         for a in soup.findAll('a', href=True, rel=True):
  32.             if a['rel'].startswith('imageview'):
  33.                 a['src'] = a['href']
  34.                 del a['href']
  35.                 a.name = 'img'
  36.                 for x in a.findAll(True):
  37.                     x.extract()
  38.         return soup
  39.  
  40.      def postprocess_html(self, soup, first):
  41.         for base in soup.findAll('base'):
  42.             base.extract()
  43.         return soup
  44.  
  45.