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_release.recipe < prev    next >
Encoding:
Text File  |  2011-09-09  |  1.7 KB  |  49 lines

  1. import re
  2. from calibre.web.feeds.news import BasicNewsRecipe
  3.  
  4. class CNetJapanRelease(BasicNewsRecipe):
  5.     title          = u'CNET Japan release'
  6.     oldest_article = 3
  7.     max_articles_per_feed = 30
  8.     __author__  = 'Hiroshi Miura'
  9.  
  10.     feeds          = [(u'CNet Release', u'http://feed.japan.cnet.com/rss/release/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.                     ]
  32.     remove_tags_after = {'class':"block20"}
  33.  
  34.     def parse_feeds(self):
  35.  
  36.         feeds = BasicNewsRecipe.parse_feeds(self)
  37.  
  38.         for curfeed in feeds:
  39.             delList = []
  40.             for a,curarticle in enumerate(curfeed.articles):
  41.                 if re.search(r'pheedo.jp', curarticle.url):
  42.                     delList.append(curarticle)
  43.             if len(delList)>0:
  44.                 for d in delList:
  45.                     index = curfeed.articles.index(d)
  46.                     curfeed.articles[index:index+1] = []
  47.  
  48.         return feeds
  49.