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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
  5. '''
  6. usatoday.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class USAToday(BasicNewsRecipe):
  12.  
  13.     title = 'USA Today'
  14.     __author__ = 'Kovid Goyal'
  15.     oldest_article = 1
  16.     timefmt  = ''
  17.     max_articles_per_feed = 20
  18.     language = 'en'
  19.     no_stylesheets = True
  20.     extra_css = '.headline      {text-align:    left;}\n    \
  21.                  .byline        {font-family:   monospace;  \
  22.                                  text-align:    left;       \
  23.                                  margin-bottom: 1em;}\n     \
  24.                  .image         {text-align:    center;}\n  \
  25.                  .caption       {text-align:    center;     \
  26.                                  font-size:     smaller;    \
  27.                                  font-style:    italic}\n   \
  28.                  .credit        {text-align:    right;      \
  29.                                  margin-bottom: 0em;        \
  30.                                  font-size:     smaller;}\n \
  31.                  .articleBody   {text-align:    left;}\n    '
  32.     #simultaneous_downloads = 1
  33.     feeds =  [
  34.                 ('Top Headlines', 'http://rssfeeds.usatoday.com/usatoday-NewsTopStories'),
  35.                 ('Tech Headlines', 'http://rssfeeds.usatoday.com/usatoday-TechTopStories'),
  36.                 ('Personal Tech', 'http://rssfeeds.usatoday.com/UsatodaycomTech-PersonalTalk'),
  37.                 ('Science', 'http://rssfeeds.usatoday.com/TP-ScienceFair'),
  38.                 ('Health', 'http://rssfeeds.usatoday.com/UsatodaycomHealth-TopStories'),
  39.                 ('Travel Headlines', 'http://rssfeeds.usatoday.com/UsatodaycomTravel-TopStories'),
  40.                 ('Money Headlines', 'http://rssfeeds.usatoday.com/UsatodaycomMoney-TopStories'),
  41.                 ('Entertainment Headlines', 'http://rssfeeds.usatoday.com/usatoday-LifeTopStories'),
  42.                 ('Sport Headlines', 'http://rssfeeds.usatoday.com/UsatodaycomSports-TopStories'),
  43.                 ('Weather Headlines', 'http://rssfeeds.usatoday.com/usatoday-WeatherTopStories'),
  44.                 ('Most Popular', 'http://rssfeeds.usatoday.com/Usatoday-MostViewedArticles'),
  45.                 ('Offbeat News', 'http://rssfeeds.usatoday.com/UsatodaycomOffbeat-TopStories'),
  46.                 ]
  47.     keep_only_tags = [dict(attrs={'class':'story'})]
  48.     remove_tags = [
  49.             dict(attrs={'class':[
  50.                                 'share',
  51.                                 'reprints',
  52.                                 'inline-h3',
  53.                                 'info-extras',
  54.                                 'ppy-outer',
  55.                                 'ppy-caption',
  56.                                 'comments',
  57.                                 'jump',
  58.                                 'pagetools',
  59.                                 'post-attributes',
  60.                                 'tags',
  61.                                 'bottom-tools',
  62.                                 'sponsoredlinks',
  63.                                 ]}),
  64.             dict(id=['pluck']),
  65.                   ]
  66.  
  67.  
  68.     def get_masthead_url(self):
  69.         masthead = 'http://i.usatoday.net/mobile/_common/_images/565x73_usat_mobile.gif'
  70.         br = BasicNewsRecipe.get_browser()
  71.         try:
  72.             br.open(masthead)
  73.         except:
  74.             self.log("\nCover unavailable")
  75.             masthead = None
  76.         return masthead
  77.  
  78.  
  79.