| 1 |
# -*- coding: utf-8 -*- |
| 2 |
__license__ = 'GPL v3' |
| 3 |
__copyright__ = '2011 Aurélien Chabot <[email protected]>' |
| 4 |
''' |
| 5 |
Lexpress.fr |
| 6 |
''' |
| 7 |
from calibre.web.feeds.recipes import BasicNewsRecipe |
| 8 |
|
| 9 |
|
| 10 |
def classes(classes): |
| 11 |
q = frozenset(classes.split(' ')) |
| 12 |
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)}) |
| 13 |
|
| 14 |
|
| 15 |
class lepoint(BasicNewsRecipe): |
| 16 |
title = "L'express" |
| 17 |
__author__ = 'calibre' |
| 18 |
description = 'Actualités' |
| 19 |
publisher = 'LExpress.fr' |
| 20 |
category = 'Actualité, France, Monde' |
| 21 |
language = 'fr' |
| 22 |
|
| 23 |
use_embedded_content = False |
| 24 |
timefmt = ' [%d %b %Y]' |
| 25 |
max_articles_per_feed = 15 |
| 26 |
no_stylesheets = True |
| 27 |
remove_empty_feeds = True |
| 28 |
filterDuplicates = True |
| 29 |
|
| 30 |
extra_css = ''' |
| 31 |
h1 {font-size:xx-large; font-family:Arial,Helvetica,sans-serif;} |
| 32 |
.current_parent, p.heure, .ouverture {font-size:xx-small; color:#4D4D4D; font-family:Arial,Helvetica,sans-serif;} |
| 33 |
#contenu-article {font-size:medium; font-family:Arial,Helvetica,sans-serif;} |
| 34 |
.entete { font-weiht:bold;} |
| 35 |
''' |
| 36 |
|
| 37 |
remove_tags = [ |
| 38 |
dict(name='iframe'), |
| 39 |
dict(name='div', attrs={'class': ['barre-outil-fb']}), |
| 40 |
dict(name='div', attrs={'class': ['barre-outils']}), |
| 41 |
dict(id='bloc-sommaire'), |
| 42 |
dict(id='footer-article'), |
| 43 |
] |
| 44 |
|
| 45 |
keep_only_tags = [classes('article_header_content article_content')] |
| 46 |
|
| 47 |
feeds = [ |
| 48 |
('À la une', 'http://www.lexpress.fr/rss/alaune.xml'), |
| 49 |
('International', 'http://www.lexpress.fr/rss/monde.xml'), |
| 50 |
('Tech/Web', 'http://www.lexpress.fr/rss/high-tech.xml'), |
| 51 |
('Sciences/Santé', 'http://www.lexpress.fr/rss/science-et-sante.xml'), |
| 52 |
('Envronnement', 'http://www.lexpress.fr/rss/environnement.xml'), |
| 53 |
('Economie', 'http://www.lepoint.fr/economie/rss.xml'), |
| 54 |
('Socièté', 'http://www.lexpress.fr/rss/societe.xml'), |
| 55 |
('Politique', 'http://www.lexpress.fr/rss/politique.xml'), |
| 56 |
('Médias', 'http://www.lexpress.fr/rss/medias.xml'), |
| 57 |
('Culture', 'http://www.lexpress.fr/rss/culture.xml'), |
| 58 |
('Sport', 'http://www.lexpress.fr/rss/sport.xml'), |
| 59 |
] |
| 60 |
|
| 61 |
def preprocess_html(self, soup): |
| 62 |
for item in soup.findAll(style=True): |
| 63 |
del item['style'] |
| 64 |
return soup |
| 65 |
|
| 66 |
def get_masthead_url(self): |
| 67 |
masthead = 'http://static.lexpress.fr/imgstat/logo_lexpress.gif' |
| 68 |
br = BasicNewsRecipe.get_browser(self) |
| 69 |
try: |
| 70 |
br.open(masthead) |
| 71 |
except Exception: |
| 72 |
self.log('\nCover unavailable') |
| 73 |
masthead = None |
| 74 |
return masthead |