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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010-2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. foxnews.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class FoxNews(BasicNewsRecipe):
  10.     title                 = 'FOX News'
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'Breaking News from FOX'
  13.     publisher             = 'FOXNews.com'
  14.     category              = 'news, breaking news, latest news, current news, world news, national news, USA'
  15.     oldest_article        = 2
  16.     max_articles_per_feed = 200
  17.     no_stylesheets        = True
  18.     encoding              = 'utf8'
  19.     use_embedded_content  = False
  20.     language              = 'en'
  21.     publication_type      = 'newsportal'
  22.     remove_empty_feeds    = True
  23.     extra_css             = """
  24.                                 body{font-family: Arial,sans-serif }
  25.                                 .caption{font-size: x-small}
  26.                                 .author,.dateline{font-size: small}
  27.                             """
  28.  
  29.     conversion_options = {
  30.                           'comment'   : description
  31.                         , 'tags'      : category
  32.                         , 'publisher' : publisher
  33.                         , 'language'  : language
  34.                         }
  35.  
  36.     remove_attributes = ['xmlns','lang']
  37.  
  38.     remove_tags=[
  39.                   dict(attrs={'class':['user-control','logo','ad-300x250','url-description']})
  40.                  ,dict(name=['meta','base','link','iframe','object','embed'])
  41.                 ]
  42.  
  43.     keep_only_tags=[dict(attrs={'id':'article-print'})]
  44.     remove_tags_after =dict(attrs={'class':'url-description'})
  45.  
  46.     feeds = [
  47.               (u'Latest Headlines', u'http://feeds.foxnews.com/foxnews/latest'        )
  48.              ,(u'National'        , u'http://feeds.foxnews.com/foxnews/national'      )
  49.              ,(u'World'           , u'http://feeds.foxnews.com/foxnews/world'         )
  50.              ,(u'Politics'        , u'http://feeds.foxnews.com/foxnews/politics'      )
  51.              ,(u'Business'        , u'http://feeds.foxnews.com/foxnews/business'      )
  52.              ,(u'SciTech'         , u'http://feeds.foxnews.com/foxnews/scitech'       )
  53.              ,(u'Health'          , u'http://feeds.foxnews.com/foxnews/health'        )
  54.              ,(u'Entertainment'   , u'http://feeds.foxnews.com/foxnews/entertainment' )
  55.             ]
  56.  
  57.     def print_version(self, url):
  58.         return url + 'print'
  59.  
  60.     def preprocess_html(self, soup):
  61.         for item in soup.findAll(style=True):
  62.             del item['style']
  63.         for item in soup.findAll('a'):
  64.             limg = item.find('img')
  65.             if item.string is not None:
  66.                str = item.string
  67.                item.replaceWith(str)
  68.             else:
  69.                if limg:
  70.                   item.name = 'div'
  71.                   item.attrs = []
  72.                else:
  73.                    str = self.tag_to_string(item)
  74.                    item.replaceWith(str)
  75.         for item in soup.findAll('img'):
  76.             if not item.has_key('alt'):
  77.                item['alt'] = 'image'
  78.         return soup
  79.