__license__ = 'GPL v3' __copyright__ = '2008, Kovid Goyal ' ''' Profile to download CNN ''' import re from calibre.web.feeds.news import BasicNewsRecipe class CNN(BasicNewsRecipe): title = 'CNN' description = 'Global news' timefmt = ' [%d %b %Y]' __author__ = 'Kovid Goyal' language = 'en' no_stylesheets = True use_embedded_content = False oldest_article = 15 #recursions = 1 #match_regexps = [r'http://sportsillustrated.cnn.com/.*/[1-9].html'] max_articles_per_feed = 25 preprocess_regexps = [ (re.compile(r'', re.DOTALL), lambda m: ''), (re.compile(r'', re.DOTALL), lambda m: ''), (re.compile(r'', re.DOTALL), lambda m: ''), ] keep_only_tags = [dict(id=['cnnContentContainer', 'storycontent'])] remove_tags = [ {'class':['cnn_strybtntools', 'cnn_strylftcntnt', 'cnn_strybtntools', 'cnn_strybtntoolsbttm', 'cnn_strybtmcntnt', 'cnn_strycntntrgt', 'hed_side', 'foot']}, dict(id=['ie_column']), ] feeds = [ ('Top News', 'http://rss.cnn.com/rss/cnn_topstories.rss'), ('World', 'http://rss.cnn.com/rss/cnn_world.rss'), ('U.S.', 'http://rss.cnn.com/rss/cnn_us.rss'), #('Sports', 'http://rss.cnn.com/rss/si_topstories.rss'), ('Business', 'http://rss.cnn.com/rss/money_latest.rss'), ('Politics', 'http://rss.cnn.com/rss/cnn_allpolitics.rss'), ('Law', 'http://rss.cnn.com/rss/cnn_law.rss'), ('Technology', 'http://rss.cnn.com/rss/cnn_tech.rss'), ('Science & Space', 'http://rss.cnn.com/rss/cnn_space.rss'), ('Health', 'http://rss.cnn.com/rss/cnn_health.rss'), ('Entertainment', 'http://rss.cnn.com/rss/cnn_showbiz.rss'), ('Education', 'http://rss.cnn.com/rss/cnn_education.rss'), ('Offbeat', 'http://rss.cnn.com/rss/cnn_offbeat.rss'), ('Most Popular', 'http://rss.cnn.com/rss/cnn_mostpopular.rss') ] def get_article_url(self, article): ans = BasicNewsRecipe.get_article_url(self, article) return ans.partition('?')[0]