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