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

  1. import re
  2. from calibre.web.feeds.news import BasicNewsRecipe
  3.  
  4. class CNetJapanDigital(BasicNewsRecipe):
  5.     title          = u'CNET Japan Digital'
  6.     oldest_article = 3
  7.     max_articles_per_feed = 30
  8.     __author__  = 'Hiroshi Miura'
  9.  
  10.     feeds          = [(u'CNet digital',u'http://feed.japan.cnet.com/rss/digital/index.rdf') ]
  11.     language       = 'ja'
  12.     encoding       = 'Shift_JIS'
  13.     remove_javascript = True
  14.  
  15.     preprocess_regexps = [
  16.        (re.compile(ur'<!--\u25B2contents_left END\u25B2-->.*</body>', re.DOTALL|re.IGNORECASE|re.UNICODE),
  17.         lambda match: '</body>'),
  18.        (re.compile(r'<!--AD_ELU_HEADER-->.*</body>', re.DOTALL|re.IGNORECASE),
  19.         lambda match: '</body>'),
  20.        (re.compile(ur'<!-- \u25B2\u95A2\u9023\u30BF\u30B0\u25B2 -->.*<!-- \u25B2ZDNet\u25B2 -->', re.UNICODE),
  21.         lambda match: '<!-- removed -->'),
  22.         ]
  23.  
  24.     remove_tags_before = dict(id="contents_l")
  25.     remove_tags = [
  26.                    {'class':"social_bkm_share"},
  27.                    {'class':"social_bkm_print"},
  28.                    {'class':"block20 clearfix"},
  29.                    dict(name="div",attrs={'id':'bookreview'}),
  30.                    {'class':"tag_left_ttl"},
  31.                    {'class':"tag_right"}
  32.                     ]
  33.     remove_tags_after = {'class':"block20"}
  34.  
  35.     def parse_feeds(self):
  36.  
  37.         feeds = BasicNewsRecipe.parse_feeds(self)
  38.  
  39.         for curfeed in feeds:
  40.             delList = []
  41.             for a,curarticle in enumerate(curfeed.articles):
  42.                 if re.search(r'pheedo.jp', curarticle.url):
  43.                     delList.append(curarticle)
  44.             if len(delList)>0:
  45.                 for d in delList:
  46.                     index = curfeed.articles.index(d)
  47.                     curfeed.articles[index:index+1] = []
  48.  
  49.         return feeds
  50.