| 1 |
__license__ = 'GPL v3' |
| 2 |
__copyright__ = '2010, Hiroshi Miura <[email protected]>' |
| 3 |
''' |
| 4 |
www.mainichi.jp |
| 5 |
''' |
| 6 |
|
| 7 |
import re |
| 8 |
|
| 9 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 10 |
|
| 11 |
|
| 12 |
class MainichiDailyScienceNews(BasicNewsRecipe): |
| 13 |
title = '\u6bce\u65e5\u65b0\u805e(Science)' |
| 14 |
__author__ = 'Hiroshi Miura' |
| 15 |
oldest_article = 2 |
| 16 |
max_articles_per_feed = 20 |
| 17 |
description = 'Japanese traditional newspaper Mainichi Daily News - science' |
| 18 |
publisher = 'Mainichi Daily News' |
| 19 |
category = 'news, japan' |
| 20 |
language = 'ja' |
| 21 |
index = 'http://mainichi.jp/select/science' |
| 22 |
remove_javascript = True |
| 23 |
masthead_title = 'MAINICHI DAILY NEWS' |
| 24 |
|
| 25 |
remove_tags_before = {'class': 'NewsTitle'} |
| 26 |
remove_tags_after = {'class': 'NewsBody clr'} |
| 27 |
|
| 28 |
def parse_feeds(self): |
| 29 |
|
| 30 |
feeds = BasicNewsRecipe.parse_feeds(self) |
| 31 |
|
| 32 |
for curfeed in feeds: |
| 33 |
delList = [] |
| 34 |
for a, curarticle in enumerate(curfeed.articles): |
| 35 |
if re.search(r'rssad.jp', curarticle.url): |
| 36 |
delList.append(curarticle) |
| 37 |
if len(delList) > 0: |
| 38 |
for d in delList: |
| 39 |
index = curfeed.articles.index(d) |
| 40 |
curfeed.articles[index : index + 1] = [] |
| 41 |
|
| 42 |
return feeds |
| 43 |
|
| 44 |
def parse_index(self): |
| 45 |
feeds = [] |
| 46 |
soup = self.index_to_soup(self.index) |
| 47 |
topstories = soup.find('ul', attrs={'class': 'MaiLink'}) |
| 48 |
if topstories: |
| 49 |
newsarticles = [] |
| 50 |
for itt in topstories.findAll('li'): |
| 51 |
itema = itt.find('a', href=True) |
| 52 |
if itema: |
| 53 |
newsarticles.append({'title': itema.string, 'date': '', 'url': itema['href'], 'description': ''}) |
| 54 |
feeds.append(('Science', newsarticles)) |
| 55 |
return feeds |