home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3761 < prev    next >
Encoding:
Text File  |  2010-04-18  |  3.4 KB  |  75 lines

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. foxnews.com
  5. '''
  6.  
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class FoxNews(BasicNewsRecipe):
  11.     title                 = 'FOX News'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Breaking News from FOX'
  14.     publisher             = 'FOXNews.com'
  15.     category              = 'news, breaking news, latest news, current news, world news, national news, USA'
  16.     oldest_article        = 2
  17.     max_articles_per_feed = 200
  18.     no_stylesheets        = True
  19.     encoding              = 'utf8'
  20.     use_embedded_content  = False
  21.     language              = 'en'
  22.     publication_type      = 'newsportal'
  23.     remove_empty_feeds    = True
  24.     extra_css             = ' body{font-family: Arial,sans-serif } img{margin-bottom: 0.4em} .caption{font-size: x-small} '
  25.  
  26.     preprocess_regexps = [
  27.        (re.compile(r'</title>.*?</head>', re.DOTALL|re.IGNORECASE),lambda match: '</title></head>')
  28.     ]
  29.  
  30.     conversion_options = {
  31.                           'comment'   : description
  32.                         , 'tags'      : category
  33.                         , 'publisher' : publisher
  34.                         , 'language'  : language
  35.                         }
  36.  
  37.     remove_attributes = ['xmlns']
  38.  
  39.     keep_only_tags      = [
  40.                             dict(name='div', attrs={'id'   :['story','browse-story-content']})
  41.                            ,dict(name='div', attrs={'class':['posts articles','slideshow']})
  42.                            ,dict(name='h4' , attrs={'class':'storyDate'})
  43.                            ,dict(name='h1' , attrs={'xmlns:functx':'http://www.functx.com'})
  44.                            ,dict(name='div', attrs={'class':'authInfo'})
  45.                            ,dict(name='div', attrs={'id':'articleCont'})
  46.                           ]
  47.  
  48.     remove_tags = [
  49.                      dict(name='div', attrs={'class':['share-links','quigo quigo2','share-text','storyControls','socShare','btm-links']})
  50.                     ,dict(name='div', attrs={'id'   :['otherMedia','loomia_display','img-all-path','story-vcmId','story-url','pane-browse-story-comments','story_related']})
  51.                     ,dict(name='ul' , attrs={'class':['tools','tools alt','tools alt2','tabs']})
  52.                     ,dict(name='a' , attrs={'class':'join-discussion'})
  53.                     ,dict(name='ul' , attrs={'class':['tools','tools alt','tools alt2']})
  54.                     ,dict(name='p' , attrs={'class':'see_fullarchive'})
  55.                     ,dict(name=['object','embed','link','script'])
  56.                   ]
  57.  
  58.  
  59.     feeds = [
  60.               (u'Latest Headlines', u'http://feeds.foxnews.com/foxnews/latest'        )
  61.              ,(u'National'        , u'http://feeds.foxnews.com/foxnews/national'      )
  62.              ,(u'World'           , u'http://feeds.foxnews.com/foxnews/world'         )
  63.              ,(u'Politics'        , u'http://feeds.foxnews.com/foxnews/politics'      )
  64.              ,(u'Business'        , u'http://feeds.foxnews.com/foxnews/business'      )
  65.              ,(u'SciTech'         , u'http://feeds.foxnews.com/foxnews/scitech'       )
  66.              ,(u'Health'          , u'http://feeds.foxnews.com/foxnews/health'        )
  67.              ,(u'Entertainment'   , u'http://feeds.foxnews.com/foxnews/entertainment' )
  68.             ]
  69.  
  70.     def preprocess_html(self, soup):
  71.         for item in soup.findAll(style=True):
  72.             del item['style']
  73.         return self.adeify_images(soup)
  74.  
  75.