| 1 |
import re |
| 2 |
|
| 3 |
from calibre.web.feeds.recipes import BasicNewsRecipe |
| 4 |
|
| 5 |
# Comment out sections you are not interested in |
| 6 |
sections = [ |
| 7 |
('정치', 'politics'), |
| 8 |
('사회', 'national'), |
| 9 |
('경제', 'economy'), |
| 10 |
('국제', 'international'), |
| 11 |
('사설칼럼', 'editorials'), |
| 12 |
('의학과학', 'science'), |
| 13 |
('문화연예', 'culture'), |
| 14 |
('스포츠', 'sports'), |
| 15 |
('사람속으로', 'inmul'), |
| 16 |
# Following sections are marked as marked optional |
| 17 |
# as default. Uncomment to enable. |
| 18 |
# (u'건강', 'health'), |
| 19 |
# (u'레저', 'leisure'), |
| 20 |
# (u'도서', 'book'), |
| 21 |
# (u'공연', 'show'), |
| 22 |
# (u'여성', 'woman'), |
| 23 |
# (u'여행', 'travel'), |
| 24 |
# (u'생활정보', 'lifeinfo'), |
| 25 |
] |
| 26 |
|
| 27 |
|
| 28 |
class Donga(BasicNewsRecipe): |
| 29 |
language = 'ko' |
| 30 |
title = '동아일보' |
| 31 |
description = '동아일보 기사' |
| 32 |
__author__ = 'Minsik Cho' |
| 33 |
ignore_duplicate_articles = {'title', 'url'} |
| 34 |
compress_news_images = True |
| 35 |
no_stylesheets = True |
| 36 |
oldest_article = 2 |
| 37 |
encoding = 'utf-8' |
| 38 |
|
| 39 |
# RSS Feed in syntax: |
| 40 |
# https://rss.donga.com/[sections].xml |
| 41 |
feeds = [(title, 'https://rss.donga.com/' + section + '.xml') for (title, section) in sections] |
| 42 |
|
| 43 |
# Remove logo and print buttons |
| 44 |
remove_tags = [ |
| 45 |
dict(name='div', attrs={'class': 'popHeaderWrap'}), |
| 46 |
dict(name='div', attrs={'class': 'etc'}), |
| 47 |
] |
| 48 |
|
| 49 |
def print_version(self, url): |
| 50 |
# Original url in syntax: |
| 51 |
# https://www.donga.com/news/[sections]/article/all/[date]/[gid]/1 |
| 52 |
# Return print version url with syntax: |
| 53 |
# https://www.donga.com/news/View?gid=[gid]&date=[date] |
| 54 |
reobject = re.search(r'(?<=/all/)([0-9]*)/([0-9]*)', url) |
| 55 |
date = reobject.group(1) |
| 56 |
gid = reobject.group(2) |
| 57 |
|
| 58 |
return 'https://www.donga.com/news/View?gid=' + gid + '&date=' + date |