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

  1. # -*- coding: utf-8 -*-
  2. from calibre.web.feeds.recipes import BasicNewsRecipe
  3. class AdvancedUserRecipe1303841067(BasicNewsRecipe):
  4.  
  5.     title          = u'Bild.de'
  6.     __author__  = 'schuster'
  7.     oldest_article = 1
  8.     max_articles_per_feed = 100
  9.     no_stylesheets         = True
  10.     use_embedded_content   = False
  11.     language               = 'de'
  12.     remove_javascript      = True
  13.  
  14. # get cover from myspace
  15.     cover_url = 'http://a3.l3-images.myspacecdn.com/images02/56/0232f842170b4d349779f8379c27e073/l.jpg'
  16.     masthead_url = 'http://a3.l3-images.myspacecdn.com/images02/56/0232f842170b4d349779f8379c27e073/l.jpg'
  17.  
  18. # set what to fetch on the site
  19.     remove_tags_before =  dict(name = 'h2', attrs={'id':'cover'})
  20.     remove_tags_after = dict(name ='div', attrs={'class':'back'})
  21.  
  22.  
  23. # remove things on the site that we don't want
  24.     remove_tags = [dict(name='div', attrs={'class':'credit'}),
  25.         dict(name='div', attrs={'class':'index'}),
  26.         dict(name='div', attrs={'id':'zstart31'}),
  27.         dict(name='div', attrs={'class':'hentry'}),
  28.         dict(name='div', attrs={'class':'back'}),
  29.         dict(name='div', attrs={'class':'pagination'}),
  30.         dict(name='div', attrs={'class':'header'}),
  31.         dict(name='div', attrs={'class':'element floatL'}),
  32.         dict(name='div', attrs={'class':'stWrap'})
  33. ]
  34.  
  35. #  thanx to kiklop74 for code (see sticky thread -> Recipes - Re-usable code)
  36. # this one removes a lot of direct-link's
  37.     def preprocess_html(self, soup):
  38.         for alink in soup.findAll('a'):
  39.             if alink.string is not None:
  40.                tstr = alink.string
  41.                alink.replaceWith(tstr)
  42.         return soup
  43.  
  44. # remove the ad's
  45.     filter_regexps = [r'.\.smartadserver\.com']
  46.     def skip_ad_pages(self, soup):
  47.         return None
  48.  
  49. #get the real url behind  .feedsportal.com and fetch the artikels
  50.     def get_article_url(self, article):
  51.         return article.get('id', article.get('guid', None))
  52.  
  53. #list of the rss source from www.bild.de
  54.     feeds          = [(u'├£berblick', u'http://rss.bild.de/bild.xml'),
  55.                           (u'News', u'http://rss.bild.de/bild-news.xml'),
  56.                           (u'Politik', u'http://rss.bild.de/bild-politik.xml'),
  57.                           (u'Unterhaltung', u'http://rss.bild.de/bild-unterhaltung.xml'),
  58.                           (u'Sport', u'http://rss.bild.de/bild-sport.xml'),
  59.                           (u'Lifestyle', u'http://rss.bild.de/bild-lifestyle.xml'),
  60.                           (u'Ratgeber', u'http://rss.bild.de/bild-ratgeber.xml'),
  61.                           (u'Reg. - Berlin', u'http://rss.bild.de/bild-berlin.xml'),
  62.                           (u'Reg. - Bremen', u'http://rss.bild.de/bild-bremen.xml'),
  63.                           (u'Reg. - Dresden', u'http://rss.bild.de/bild-dresden.xml'),
  64.                           (u'Reg. - D├╝sseldorf', u'http://rss.bild.de/bild-duesseldorf.xml'),
  65.                           (u'Reg. - Frankfurt-Main', u'http://rss.bild.de/bild-frankfurt-main.xml'),
  66.                           (u'Reg. - Hamburg', u'http://rss.bild.de/bild-hamburg.xml'),
  67.                           (u'Reg. - Hannover', u'http://rss.bild.de/bild-hannover.xml'),
  68.                           (u'Reg. - K├╢ln', u'http://rss.bild.de/bild-koeln.xml'),
  69.                           (u'Reg. - Leipzig', u'http://rss.bild.de/bild-leipzig.xml'),
  70.                           (u'Reg. - M├╝nchen', u'http://rss.bild.de/bild-muenchen.xml'),
  71.                           (u'Reg. - Ruhrgebiet', u'http://rss.bild.de/bild-ruhrgebiet.xml'),
  72.                           (u'Reg. - Stuttgart', u'http://rss.bild.de/bild-stuttgart.xml')
  73. ]
  74.  
  75.