![]() |
#1 |
plus ça change
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 101
Karma: 32134
Join Date: Dec 2009
Location: France
Device: Kindle PW2, Voyage
|
Updated recipe for Le Monde?
Just wondering if some kind soul could update the recipe for Le Monde. I have tried playing around a bit with the built-in recipe, but it looks like the website has undergone a lot of changes since the recipe was written, and the results I'm getting are pretty hit-and-miss. Any help greatly appreciated!
![]() Edit: sorry, here's the link to the feeds: http://www.lemonde.fr/web/rss/0,48-0,1-0,0.html Last edited by veezh; 12-06-2010 at 08:06 AM. |
![]() |
![]() |
![]() |
#2 |
Train reader
![]() Posts: 10
Karma: 15
Join Date: Nov 2010
Device: Kindle3
|
I would be interested, too.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
plus ça change
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 101
Karma: 32134
Join Date: Dec 2009
Location: France
Device: Kindle PW2, Voyage
|
Just in case others may get some use out of this, I cobbled together my own recipe for Le Monde (I'm not a programmer, and my python skills are very limited), but it seems to be working OK.
The recipe also cleans up the non-typographical quotation marks used on the site, replacing them with proper guillemets (angle bracket quotes) and non-breaking spaces. Code:
import re from calibre.web.feeds.recipes import BasicNewsRecipe class LeMonde(BasicNewsRecipe): title = 'Le Monde' description = 'Actualités' oldest_article = 1 max_articles_per_feed = 100 no_stylesheets = True #delay = 1 use_embedded_content = False encoding = 'cp1252' publisher = 'lemonde.fr' language = 'fr_FR' conversion_options = { 'comments' : description ,'tags' : category ,'language' : language ,'publisher' : publisher ,'linearize_tables': True } remove_empty_feeds = True filterDuplicates = True def preprocess_html(self, soup): for alink in soup.findAll('a'): if alink.string is not None: tstr = alink.string alink.replaceWith(tstr) return soup preprocess_regexps = [ (re.compile(r' \''), lambda match: ' ‘'), (re.compile(r'\''), lambda match: '’'), (re.compile(r'"<'), lambda match: ' »<'), (re.compile(r'>"'), lambda match: '>« '), (re.compile(r'’"'), lambda match: '’« '), (re.compile(r' "'), lambda match: ' « '), (re.compile(r'" '), lambda match: ' » '), (re.compile(r'\("'), lambda match: '(« '), (re.compile(r'"\)'), lambda match: ' »)'), (re.compile(r'"\.'), lambda match: ' ».'), (re.compile(r'",'), lambda match: ' »,'), (re.compile(r'"\?'), lambda match: ' »?'), (re.compile(r'":'), lambda match: ' »:'), (re.compile(r'";'), lambda match: ' »;'), (re.compile(r'"\!'), lambda match: ' »!'), (re.compile(r' :'), lambda match: ' :'), (re.compile(r' ;'), lambda match: ' ;'), (re.compile(r' \?'), lambda match: ' ?'), (re.compile(r' \!'), lambda match: ' !'), (re.compile(r'\s»'), lambda match: ' »'), (re.compile(r'«\s'), lambda match: '« '), (re.compile(r' %'), lambda match: ' %'), (re.compile(r'\.jpg » border='), lambda match: '.jpg'), (re.compile(r'\.png » border='), lambda match: '.png'), ] keep_only_tags = [ dict(name='div', attrs={'class':['contenu']}) ] remove_tags_after = [dict(id='appel_temoignage')] def get_article_url(self, article): link = article.get('link') if 'blog' not in link: return link feeds = [ ('A la une', 'http://www.lemonde.fr/rss/une.xml'), ('International', 'http://www.lemonde.fr/rss/tag/international.xml'), ('Europe', 'http://www.lemonde.fr/rss/tag/europe.xml'), (u'Société', 'http://www.lemonde.fr/rss/tag/societe.xml'), ('Economie', 'http://www.lemonde.fr/rss/tag/economie.xml'), (u'Médias', 'http://www.lemonde.fr/rss/tag/actualite-medias.xml'), (u'Planète', 'http://www.lemonde.fr/rss/tag/planete.xml'), ('Culture', 'http://www.lemonde.fr/rss/tag/culture.xml'), ('Technologies', 'http://www.lemonde.fr/rss/tag/technologies.xml'), ('Livres', 'http://www.lemonde.fr/rss/tag/livres.xml'), ] def get_cover_url(self): cover_url = None soup = self.index_to_soup('http://www.lemonde.fr/web/monde_pdf/0,33-0,1-0,0.html') link_item = soup.find('div',attrs={'class':'pg-gch'}) if link_item and link_item.img: cover_url = link_item.img['src'] return cover_url Last edited by veezh; 12-09-2010 at 06:59 AM. |
![]() |
![]() |
![]() |
#4 |
Train reader
![]() Posts: 10
Karma: 15
Join Date: Nov 2010
Device: Kindle3
|
Merci beaucoup :-)
That seems to be working. The only change I had to make, was to remove the conversion options. They caused error messages. |
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 1
Karma: 10
Join Date: Dec 2010
Device: Sony PRS-650
|
Hello,
The Epub file generated from "Le Monde" Recipe is not correctly displayed on the Sony PRS-650 : pages containing picture are blank after the title. Is there a way to discard the pictures in the conversion process, or from the recipe ? Thanks ! ![]() |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Can one read too much?
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,029
Karma: 2487799
Join Date: Aug 2010
Location: Naples, FL
Device: Kindle PW 3, Sony 350 and 650
|
I tried a couple of days ago - some articles were okay, some were only headlines, with no "body" - is that because it's a pay site?
|
![]() |
![]() |
![]() |
Tags |
french, monde, recipe |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Updated Telepolis (News+Artikel) Recipe | syntaxis | Recipes | 8 | 05-15-2011 06:40 AM |
Updated New York Times recipe | nickredding | Recipes | 2 | 11-20-2010 10:53 AM |
[Updated recipe] Ming Pao (明報) - Hong Kong | tylau0 | Recipes | 0 | 11-06-2010 06:46 PM |
Request for Le Monde Diplo En archive recipe | michaelernst | Recipes | 6 | 10-17-2010 11:13 AM |
Updated New Yorker recipe doesn't fetch comics | yekim54 | Recipes | 2 | 10-09-2010 10:47 PM |