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

  1. #!/usr/bin/env  python
  2. __license__   = 'GPL v3'
  3. __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
  4. __docformat__ = 'restructuredtext en'
  5.  
  6. '''
  7. businessweek.com
  8. '''
  9.  
  10. from calibre.web.feeds.news import BasicNewsRecipe
  11.  
  12. class BusinessWeek(BasicNewsRecipe):
  13.     title          = 'Business Week'
  14.     description    = 'Business News, Stock Market and Financial Advice'
  15.     __author__     = 'ChuckEggDotCom and Sujata Raman'
  16.     language = 'en'
  17.  
  18.     oldest_article = 7
  19.     max_articles_per_feed = 10
  20.     no_stylesheets = True
  21.  
  22.     recursions = 1
  23.     match_regexps = [r'http://www.businessweek.com/.*_page_[1-9].*']
  24.     extra_css = '''
  25.                 h1{font-family :Arial,Helvetica,sans-serif; font-size:large;}
  26.                 .news_story_title{font-family :Arial,Helvetica,sans-serif; font-size:large;font-weight:bold;}
  27.                 h2{font-family :Arial,Helvetica,sans-serif; font-size:medium;color:#666666;}
  28.                 h3{text-transform:uppercase;font-family :Arial,Helvetica,sans-serif; font-size:large;font-weight:bold;}
  29.                 h4{font-family :Arial,Helvetica,sans-serif; font-size:small;font-weight:bold;}
  30.                 p{font-family :Arial,Helvetica,sans-serif; }
  31.                 #lede600{font-size:x-small;}
  32.                 #storybody{font-size:x-small;}
  33.                 p{font-family :Arial,Helvetica,sans-serif;}
  34.                 .strap{font-family :Arial,Helvetica,sans-serif; font-size:x-small; color:#064599;}
  35.                 .byline{font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
  36.                 .postedBy{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
  37.                 .trackback{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
  38.                 .date{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
  39.                 .wrapper{font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
  40.                 .photoCredit{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
  41.                 .tagline{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
  42.                 .pageCount{color:#666666;font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
  43.                 .note{font-family :Arial,Helvetica,sans-serif; font-size:small;color:#666666;font-style:italic;}
  44.                 .highlight{font-family :Arial,Helvetica,sans-serif; font-size:small;background-color:#FFF200;}
  45.                 .annotation{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}                
  46.                 '''
  47.    
  48.     remove_tags = [  dict(name='div', attrs={'id':["log","feedback","footer","secondarynav","secondnavbar","header","email","bw2-header","column2","wrapper-bw2-footer","wrapper-mgh-footer","inset","commentForm","commentDisplay","bwExtras","bw2-umbrella","readerComments","leg","rightcol"]}),
  49.                     dict(name='div', attrs={'class':["menu",'sponsorbox smallertext',"TopNavTile","graybottom leaderboard"]}),
  50.                     dict(name='img', alt ="News"),
  51.                      dict(name='td', width ="1"),
  52.                     ]
  53.  
  54.     feeds          = [
  55.                       (u'Top Stories', u'http://www.businessweek.com/topStories/rss/topStories.rss'),
  56.                       (u'Top News', u'http://www.businessweek.com/rss/bwdaily.rss'),
  57.                       (u'Asia', u'http://www.businessweek.com/rss/asia.rss'),
  58.                       (u'Autos', u'http://www.businessweek.com/rss/autos/index.rss'),
  59.                       (u'Classic Cars', u'http://rss.businessweek.com/bw_rss/classiccars'),
  60.                       (u'Hybrids', u'http://rss.businessweek.com/bw_rss/hybrids'),
  61.                       (u'Europe', u'http://www.businessweek.com/rss/europe.rss'),
  62.                       (u'Auto Reviews', u'http://rss.businessweek.com/bw_rss/autoreviews'),
  63.                       (u'Innovation & Design', u'http://www.businessweek.com/rss/innovate.rss'),
  64.                       (u'Architecture', u'http://www.businessweek.com/rss/architecture.rss'),
  65.                       (u'Brand Equity', u'http://www.businessweek.com/rss/brandequity.rss'),
  66.                       (u'Auto Design', u'http://www.businessweek.com/rss/carbuff.rss'),
  67.                       (u'Game Room', u'http://rss.businessweek.com/bw_rss/gameroom'),
  68.                       (u'Technology', u'http://www.businessweek.com/rss/technology.rss'),
  69.                       (u'Investing', u'http://rss.businessweek.com/bw_rss/investor'),
  70.                       (u'Small Business', u'http://www.businessweek.com/rss/smallbiz.rss'),
  71.                       (u'Careers', u'http://rss.businessweek.com/bw_rss/careers'),
  72.                       (u'B-Schools', u'http://www.businessweek.com/rss/bschools.rss'),
  73.                       (u'Magazine Selections', u'http://www.businessweek.com/rss/magazine.rss'),
  74.                       (u'CEO Guide to Tech', u'http://www.businessweek.com/rss/ceo_guide_tech.rss'),
  75.                       ]
  76.  
  77.     def get_article_url(self, article):
  78.  
  79.         url = article.get('guid', None)
  80.  
  81.         if 'podcasts' in url or 'surveys' in url:
  82.             url = None
  83.  
  84.         return url
  85.  
  86.     def postprocess_html(self, soup, first):
  87.  
  88.             for tag in soup.findAll(name=['ul','li','table','td','tr','span']):
  89.                 tag.name = 'div'
  90.             for tag in soup.findAll(name= 'div',attrs={ 'id':'pageNav'}):                
  91.                 tag.extract()
  92.             return soup
  93.  
  94.