| 1 |
__author__ = 'Marco Saraceno' |
| 2 |
__copyright__ = '2010, Marco Saraceno <marcosaraceno at gmail.com>' |
| 3 |
description = 'Italian daily newspaper - v 1.1 (Mar14,2011)' |
| 4 |
|
| 5 |
''' |
| 6 |
http://www.ilsole24ore.com |
| 7 |
''' |
| 8 |
|
| 9 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 10 |
|
| 11 |
|
| 12 |
def classes(classes): |
| 13 |
q = frozenset(classes.split(' ')) |
| 14 |
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)}) |
| 15 |
|
| 16 |
|
| 17 |
class IlSole24Ore(BasicNewsRecipe): |
| 18 |
__author__ = 'Marco Saraceno' |
| 19 |
description = 'Italian financial daily newspaper' |
| 20 |
|
| 21 |
cover_url = 'http://www.shopping24.ilsole24ore.com/ProductRelated/rds/img/logo_sole.gif' |
| 22 |
title = 'Il Sole 24 Ore' |
| 23 |
publisher = 'Gruppo editoriale GRUPPO 24ORE' |
| 24 |
category = 'News, politics, culture, economy, financial, Italian' |
| 25 |
|
| 26 |
language = 'it' |
| 27 |
timefmt = '[%a, %d %b, %Y]' |
| 28 |
|
| 29 |
oldest_article = 2 |
| 30 |
max_articles_per_feed = 100 |
| 31 |
use_embedded_content = False |
| 32 |
extra_css = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt }' |
| 33 |
no_stylesheets = True |
| 34 |
|
| 35 |
keep_only_tags = [classes('ahead atext')] |
| 36 |
remove_tags = [classes('ahead-ltool')] |
| 37 |
|
| 38 |
def get_article_url(self, article): |
| 39 |
link = article.get('link', None) |
| 40 |
if link is None: |
| 41 |
return article |
| 42 |
if link.split('/')[-1] == 'story01.htm': |
| 43 |
link = link.split('/')[-2] |
| 44 |
t = ( |
| 45 |
('0B', '.'), |
| 46 |
('0C', '/'), |
| 47 |
('0D', '?'), |
| 48 |
('0E', '-'), |
| 49 |
('0F', '='), |
| 50 |
('0G', '&'), |
| 51 |
('0N', '.com'), |
| 52 |
('0L0S', 'www.'), |
| 53 |
('0A', '0'), |
| 54 |
) |
| 55 |
for a, b in t: |
| 56 |
link = link.replace(a, b) |
| 57 |
link = 'http://' + link |
| 58 |
return link |
| 59 |
|
| 60 |
feeds = [ |
| 61 |
('Italia', 'https://www.ilsole24ore.com/rss/italia.xml'), |
| 62 |
('Mondo', 'https://www.ilsole24ore.com/rss/mondo.xml'), |
| 63 |
('Economia', 'https://www.ilsole24ore.com/rss/economia.xml'), |
| 64 |
('Finanzia', 'https://www.ilsole24ore.com/rss/finanza.xml'), |
| 65 |
('Commenti', 'https://www.ilsole24ore.com/rss/commenti.xml'), |
| 66 |
('Risparmio', 'https://www.ilsole24ore.com/rss/risparmio.xml'), |
| 67 |
('Norme e Tributi', 'https://www.ilsole24ore.com/rss/norme-e-tributi.xml'), |
| 68 |
('Management', 'https://www.ilsole24ore.com/rss/management.xml'), |
| 69 |
('Cultura', 'https://www.ilsole24ore.com/rss/cultura.xml'), |
| 70 |
('Tecnologia', 'https://www.ilsole24ore.com/rss/tecnologia.xml'), |
| 71 |
('Food', 'https://www.ilsole24ore.com/rss/food.xml'), |
| 72 |
('Moda', 'https://www.ilsole24ore.com/rss/moda.xml'), |
| 73 |
('Motori', 'https://www.ilsole24ore.com/rss/motori.xml'), |
| 74 |
('Casa', 'https://www.ilsole24ore.com/rss/casa.xml'), |
| 75 |
('Viaggi', 'https://www.ilsole24ore.com/rss/viaggi.xml'), |
| 76 |
('Salute', 'https://www.ilsole24ore.com/rss/salute.xml'), |
| 77 |
('Arteconomy', 'https://www.ilsole24ore.com/rss/arteconomy.xml'), |
| 78 |
('Sport', 'https://www.ilsole24ore.com/rss/sport24.xml'), |
| 79 |
] |
| 80 |
|
| 81 |
def print_version(self, url): |
| 82 |
return url.replace('.shtml', '_PRN.shtml') |