| 1 |
__license__ = 'GPL v3' |
| 2 |
__author__ = 'Lorenzo Vigentini and Olivier Daigle' |
| 3 |
__copyright__ = '2012, Lorenzo Vigentini <l.vigentini at gmail.com>, Olivier Daigle <odaigle _at nuvucameras __dot__ com>' |
| 4 |
__version__ = 'v1.01' |
| 5 |
__date__ = '17, March 2013' |
| 6 |
__description__ = 'Canadian Paper ' |
| 7 |
|
| 8 |
''' |
| 9 |
http://www.ledevoir.com/ |
| 10 |
''' |
| 11 |
|
| 12 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 13 |
|
| 14 |
|
| 15 |
def classes(classes): |
| 16 |
q = frozenset(classes.split(' ')) |
| 17 |
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)}) |
| 18 |
|
| 19 |
|
| 20 |
class ledevoir(BasicNewsRecipe): |
| 21 |
author = 'Lorenzo Vigentini' |
| 22 |
description = 'Canadian Paper. A subscription is optional, with it you get more content' |
| 23 |
|
| 24 |
cover_url = 'http://www.ledevoir.com/images/ul/graphiques/logo_devoir.gif' |
| 25 |
title = 'Le Devoir ' |
| 26 |
publisher = 'leDevoir.com' |
| 27 |
category = 'News, finance, economy, politics' |
| 28 |
|
| 29 |
language = 'fr' |
| 30 |
encoding = 'utf-8' |
| 31 |
timefmt = '[%a, %d %b, %Y]' |
| 32 |
|
| 33 |
oldest_article = 1 |
| 34 |
max_articles_per_feed = 50 |
| 35 |
min_articles_per_feed = 0 |
| 36 |
use_embedded_content = False |
| 37 |
needs_subscription = 'optional' |
| 38 |
|
| 39 |
compress_news_images = True |
| 40 |
compress_news_images_auto_size = 4 |
| 41 |
|
| 42 |
remove_javascript = True |
| 43 |
no_stylesheets = True |
| 44 |
remove_empty_feeds = True |
| 45 |
|
| 46 |
keep_only_tags = [ |
| 47 |
dict(name='h1'), |
| 48 |
dict(attrs={'class': 'col-xs-14 col-sm-7 col-md-9 col-lg-10'}), |
| 49 |
] |
| 50 |
remove_tags = [classes('category-nav social')] |
| 51 |
|
| 52 |
feeds = [ |
| 53 |
('A la une', 'http://www.ledevoir.com/rss/manchettes.xml'), |
| 54 |
('Édition complete', 'http://feeds2.feedburner.com/fluxdudevoir'), |
| 55 |
('Opinions', 'http://www.ledevoir.com/rss/opinions.xml'), |
| 56 |
('Chroniques', 'http://www.ledevoir.com/rss/chroniques.xml'), |
| 57 |
('Politique', 'http://www.ledevoir.com/rss/section/politique.xml?id=51'), |
| 58 |
('International', 'http://www.ledevoir.com/rss/section/international.xml?id=76'), |
| 59 |
('Culture', 'http://www.ledevoir.com/rss/section/culture.xml?id=48'), |
| 60 |
('Environnement', 'http://www.ledevoir.com/rss/section/environnement.xml?id=78'), |
| 61 |
('Societe', 'http://www.ledevoir.com/rss/section/societe.xml?id=52'), |
| 62 |
('Economie', 'http://www.ledevoir.com/rss/section/economie.xml?id=49'), |
| 63 |
('Sports', 'http://www.ledevoir.com/rss/section/sports.xml?id=85'), |
| 64 |
('Art de vivre', 'http://www.ledevoir.com/rss/section/art-de-vivre.xml?id=50'), |
| 65 |
] |
| 66 |
|
| 67 |
def get_browser(self): |
| 68 |
br = BasicNewsRecipe.get_browser(self) |
| 69 |
if self.username is not None and self.password is not None: |
| 70 |
br.open('http://www.ledevoir.com/auth/login') |
| 71 |
br.select_form(action='/auth/login') |
| 72 |
br['login[courriel]'] = self.username |
| 73 |
br['login[password]'] = self.password |
| 74 |
br.submit() |
| 75 |
return br |