# -*- coding: utf-8 -*- __license__ = 'GPL v3' __copyright__ = '2011 Aurélien Chabot ' ''' Lexpress.fr ''' from calibre.web.feeds.recipes import BasicNewsRecipe def classes(classes): q = frozenset(classes.split(' ')) return dict(attrs={ 'class': lambda x: x and frozenset(x.split()).intersection(q)}) class lepoint(BasicNewsRecipe): title = 'L\'express' __author__ = 'calibre' description = 'Actualités' publisher = 'LExpress.fr' category = 'Actualité, France, Monde' language = 'fr' use_embedded_content = False timefmt = ' [%d %b %Y]' max_articles_per_feed = 15 no_stylesheets = True remove_empty_feeds = True filterDuplicates = True extra_css = ''' h1 {font-size:xx-large; font-family:Arial,Helvetica,sans-serif;} .current_parent, p.heure, .ouverture {font-size:xx-small; color:#4D4D4D; font-family:Arial,Helvetica,sans-serif;} #contenu-article {font-size:medium; font-family:Arial,Helvetica,sans-serif;} .entete { font-weiht:bold;} ''' remove_tags = [ dict(name='iframe'), dict(name='div', attrs={'class': ['barre-outil-fb']}), dict(name='div', attrs={'class': ['barre-outils']}), dict(id='bloc-sommaire'), dict(id='footer-article') ] keep_only_tags = [ classes('article_header_content article_content') ] feeds = [ (u'À la une', 'http://www.lexpress.fr/rss/alaune.xml'), ('International', 'http://www.lexpress.fr/rss/monde.xml'), ('Tech/Web', 'http://www.lexpress.fr/rss/high-tech.xml'), (u'Sciences/Santé', 'http://www.lexpress.fr/rss/science-et-sante.xml'), (u'Envronnement', 'http://www.lexpress.fr/rss/environnement.xml'), ('Economie', 'http://www.lepoint.fr/economie/rss.xml'), (u'Socièté', 'http://www.lexpress.fr/rss/societe.xml'), ('Politique', 'http://www.lexpress.fr/rss/politique.xml'), (u'Médias', 'http://www.lexpress.fr/rss/medias.xml'), ('Culture', 'http://www.lexpress.fr/rss/culture.xml'), ('Sport', 'http://www.lexpress.fr/rss/sport.xml') ] def preprocess_html(self, soup): for item in soup.findAll(style=True): del item['style'] return soup def get_masthead_url(self): masthead = 'http://static.lexpress.fr/imgstat/logo_lexpress.gif' br = BasicNewsRecipe.get_browser(self) try: br.open(masthead) except: self.log("\nCover unavailable") masthead = None return masthead