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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
  3. '''
  4. Profile to download CNN
  5. '''
  6.  
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class CNN(BasicNewsRecipe):
  11.  
  12.     title = 'CNN'
  13.     description = 'Global news'
  14.     timefmt  = ' [%d %b %Y]'
  15.     __author__ = 'Kovid Goyal'
  16.     language = 'en'
  17.  
  18.     no_stylesheets = True
  19.     use_embedded_content   = False
  20.     oldest_article        = 15
  21.     #recursions = 1
  22.     #match_regexps = [r'http://sportsillustrated.cnn.com/.*/[1-9].html']
  23.     max_articles_per_feed = 25
  24.  
  25.     preprocess_regexps = [
  26.         (re.compile(r'<!--\[if.*if\]-->', re.DOTALL), lambda m: ''),
  27.         (re.compile(r'<script.*?</script>', re.DOTALL), lambda m: ''),
  28.         (re.compile(r'<style.*?</style>', re.DOTALL), lambda m: ''),
  29.     ]
  30.  
  31.     keep_only_tags = [dict(id=['cnnContentContainer', 'storycontent'])]
  32.     remove_tags = [
  33.             {'class':['cnn_strybtntools', 'cnn_strylftcntnt',
  34.                 'cnn_strybtntools', 'cnn_strybtntoolsbttm', 'cnn_strybtmcntnt',
  35.                 'cnn_strycntntrgt', 'hed_side', 'foot']},
  36.             dict(id=['ie_column']),
  37.     ]
  38.  
  39.  
  40.     feeds =  [
  41.              ('Top News', 'http://rss.cnn.com/rss/cnn_topstories.rss'),
  42.              ('World', 'http://rss.cnn.com/rss/cnn_world.rss'),
  43.              ('U.S.', 'http://rss.cnn.com/rss/cnn_us.rss'),
  44.              #('Sports', 'http://rss.cnn.com/rss/si_topstories.rss'),
  45.              ('Business', 'http://rss.cnn.com/rss/money_latest.rss'),
  46.              ('Politics', 'http://rss.cnn.com/rss/cnn_allpolitics.rss'),
  47.              ('Law', 'http://rss.cnn.com/rss/cnn_law.rss'),
  48.              ('Technology', 'http://rss.cnn.com/rss/cnn_tech.rss'),
  49.              ('Science & Space', 'http://rss.cnn.com/rss/cnn_space.rss'),
  50.              ('Health', 'http://rss.cnn.com/rss/cnn_health.rss'),
  51.              ('Entertainment', 'http://rss.cnn.com/rss/cnn_showbiz.rss'),
  52.              ('Education', 'http://rss.cnn.com/rss/cnn_education.rss'),
  53.              ('Offbeat', 'http://rss.cnn.com/rss/cnn_offbeat.rss'),
  54.              ('Most Popular', 'http://rss.cnn.com/rss/cnn_mostpopular.rss')
  55.              ]
  56.  
  57.     def get_article_url(self, article):
  58.         ans = BasicNewsRecipe.get_article_url(self, article)
  59.         return ans.partition('?')[0]
  60.  
  61.