Read CNN on your iPad or Kindle in no time. Click download to load the free ebook on your reader.

Check out all the available public recipes or write your own with these quick start guides. ReadBeam is built on calibre, so everything in the docs and the fora applies here as well.

Download for free »

Cable News Network (CNN) is a U.S. cable news channel. CNN is one of the world's largest news organizations, and its international channel, CNN International is the leading international new channel in terms of viewer reach.

Language: en

Requires Subscription: No, it's available as free ebook

Schedule Every morning

			  __license__   = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
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

    extra_css = '''
                    h1 {font-size:xx-large; font-family:Arial,Helvetica,sans-serif;}
                    .cnn_story_author, .cnn_stryathrtmp {font-size:xx-small; color:#4D4D4D; font-family:Arial,Helvetica,sans-serif;}
                    .cnn_strycaptiontxt, .cnnArticleGalleryPhotoContainer {font-size:xx-small; color:#4D4D4D; font-family:Arial,Helvetica,sans-serif;}
                    .cnn_strycbftrtxt, .cnnEditorialNote {font-size:xx-small; color:#4D4D4D; font-family:Arial,Helvetica,sans-serif;}
                    .cnn_strycntntlft {font-size:medium; font-family:Arial,Helvetica,sans-serif;}
                '''

    preprocess_regexps = [
        (re.compile(r'<!--\[if.*if\]-->', re.DOTALL), lambda m: ''),
        (re.compile(r'<script.*?</script>', re.DOTALL), lambda m: ''),
        (re.compile(r'<style.*?</style>', 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', 'cnn_strylftcntnt cnn_strylftcexpbx']},
            {'class':['cnn_html_media_title_new', 'cnn_html_media_title_new cnn_html_media_title_none',
                'cnnArticleGalleryCaptionControlText', 'articleGalleryNavContainer']},
            {'id':['articleGalleryNav00JumpPrev', 'articleGalleryNav00Prev',
                'articleGalleryNav00Next', 'articleGalleryNav00JumpNext']},
            {'style':['display:none']},
            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]

    def get_masthead_url(self):
        masthead = 'http://i.cdn.turner.com/cnn/.element/img/3.0/global/header/intl/hdr-globe-central.gif'
        br = BasicNewsRecipe.get_browser()
        try:
            br.open(masthead)
        except:
            self.log("\nCover unavailable")
            masthead = None
        return masthead