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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Hiroshi Miura <miurahr@linux.com>'
  3. '''
  4. nationalgeographic.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8. import re
  9.  
  10. class NationalGeographicNews(BasicNewsRecipe):
  11.     title          = u'National Geographic News'
  12.     oldest_article = 7
  13.     language = 'en'
  14.     max_articles_per_feed = 100
  15.     remove_javascript = True
  16.     no_stylesheets = True
  17.     use_embedded_content = False
  18.  
  19.     feeds          = [(u'news', u'http://feeds.nationalgeographic.com/ng/News/News_Main')]
  20.  
  21.     remove_tags_before = dict(id='page_head')
  22.     remove_tags_after = [dict(id='social_buttons'),{'class':'aside'}]
  23.     remove_tags = [
  24.                        {'class':'hidden'}
  25.  
  26.                      ]
  27.  
  28.     def parse_feeds(self):
  29.         feeds = BasicNewsRecipe.parse_feeds(self)
  30.         for curfeed in feeds:
  31.             delList = []
  32.             for a,curarticle in enumerate(curfeed.articles):
  33.                 if re.search(r'ads\.pheedo\.com', curarticle.url):
  34.                     delList.append(curarticle)
  35.             if len(delList)>0:
  36.                 for d in delList:
  37.                     index = curfeed.articles.index(d)
  38.                     curfeed.articles[index:index+1] = []
  39.         return feeds
  40.