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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. www.usnews.com
  7. '''
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class LaPrensa(BasicNewsRecipe):
  11.     title                 = 'US & World Report news'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'News from USA and world'
  14.     publisher             = 'U.S.News & World Report, L.P.'
  15.     category              = 'news, politics, USA'
  16.     oldest_article        = 2
  17.     max_articles_per_feed = 100
  18.     no_stylesheets        = True
  19.     use_embedded_content  = False
  20.     encoding              = 'utf-8'
  21.     language = 'en'
  22.  
  23.  
  24.     html2lrf_options = [
  25.                           '--comment', description
  26.                         , '--category', category
  27.                         , '--publisher', publisher
  28.                         ]
  29.  
  30.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
  31.  
  32.     keep_only_tags = [
  33.                         dict(name='h1')
  34.                        ,dict(name='div', attrs={'id':['dateline']})
  35.                        ,dict(name='div', attrs={'class':['blogCredit','body']})
  36.                      ]
  37.  
  38.     feeds = [
  39.               (u'Homepage'        , u'http://www.usnews.com/rss/usnews.rss'          )
  40.              ,(u'Health'          , u'http://www.usnews.com/rss/health/index.rss'    )
  41.              ,(u'Nation & World'  , u'http://www.usnews.com/rss/news/index.rss'      )
  42.              ,(u'Money & Business', u'http://www.usnews.com/rss/business/index.rss'  )
  43.              ,(u'Education'       , u'http://www.usnews.com/rss/education/index.rss' )
  44.              ,(u'Opinion'         , u'http://www.usnews.com/rss/opinion/index.rss'   )
  45.              ,(u'Science'         , u'http://www.usnews.com/rss/science/index.rss'   )
  46.             ]
  47.  
  48.     def print_version(self, url):
  49.         return url.replace('.html','_print.html')
  50.  
  51.     def get_article_url(self, article):
  52.         raw = article.get('link',  None)
  53.         artcl, sep, unneeded = raw.rpartition('?')
  54.         return artcl
  55.  
  56.     def preprocess_html(self, soup):
  57.         del soup.body['onload']
  58.         for item in soup.findAll(style=True):
  59.             del item['style']
  60.         return soup
  61.  
  62.