| 1 |
#!/usr/bin/env python |
| 2 |
# -*- coding: utf-8 mode: python -*- |
| 3 |
|
| 4 |
__license__ = 'GPL v3' |
| 5 |
__copyright__ = '2009-2015, Darko Miletic <darko.miletic at gmail.com>' |
| 6 |
__docformat__ = 'restructuredtext es' |
| 7 |
''' |
| 8 |
www.emol.com |
| 9 |
''' |
| 10 |
|
| 11 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 12 |
|
| 13 |
|
| 14 |
class ElMercurio(BasicNewsRecipe): |
| 15 |
title = 'Emol.com - El sitio de noticias online de Chile' |
| 16 |
__author__ = 'Darko Miletic' |
| 17 |
description = 'El sitio de noticias online de Chile' |
| 18 |
publisher = 'El Mercurio S.A.P.' |
| 19 |
category = 'news, politics, Chile' |
| 20 |
oldest_article = 2 |
| 21 |
max_articles_per_feed = 100 |
| 22 |
no_stylesheets = True |
| 23 |
encoding = 'utf8' |
| 24 |
masthead_url = 'http://static.emol.cl/emol50/img/logo_emol.gif' |
| 25 |
remove_javascript = True |
| 26 |
use_embedded_content = False |
| 27 |
language = 'es_CL' |
| 28 |
|
| 29 |
conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language} |
| 30 |
|
| 31 |
keep_only_tags = [ |
| 32 |
dict(name='div', attrs={'class': ['cont_iz_titulobajada', 'info-notaemol-por', 'info-notaemol-porfecha']}), |
| 33 |
dict(name='div', attrs={'id': 'texto_noticia'}), |
| 34 |
] |
| 35 |
remove_tags = [dict(name='div', attrs={'id': 'cont_iz_cuerpo_relacionados'})] |
| 36 |
|
| 37 |
feeds = [ |
| 38 |
('Nacional', 'http://www.emol.com/noticias/nacional/todas.aspx'), |
| 39 |
('Mundo', 'http://www.emol.com/noticias/internacional/todas.aspx'), |
| 40 |
('Deportes', 'http://www.emol.com/noticias/deportes/todas.aspx'), |
| 41 |
('Espectaculos', 'http://www.emol.com/noticias/cultura/todas.aspx'), |
| 42 |
('Tecnologia', 'http://www.emol.com/noticias/economia/todas.aspx'), |
| 43 |
] |
| 44 |
|
| 45 |
def parse_index(self): |
| 46 |
totalfeeds = [] |
| 47 |
lfeeds = self.get_feeds() |
| 48 |
for feedobj in lfeeds: |
| 49 |
feedtitle, feedurl = feedobj |
| 50 |
self.report_progress(0, _('Fetching feed') + ' %s...' % (feedtitle or feedurl)) |
| 51 |
articles = [] |
| 52 |
soup = self.index_to_soup(feedurl) |
| 53 |
arts = soup.find('div', attrs={'id': 'caja_listado_noticia_todas'}) |
| 54 |
if arts: |
| 55 |
for item in arts.findAll('div', attrs={'class': 'listado'}): |
| 56 |
atag = item.find('a') |
| 57 |
ptag = item.find('span') |
| 58 |
url = atag['href'] |
| 59 |
title = self.tag_to_string(atag) |
| 60 |
description = self.tag_to_string(ptag) |
| 61 |
articles.append({'title': title, 'date': '', 'url': url, 'description': description}) |
| 62 |
totalfeeds.append((feedtitle, articles)) |
| 63 |
return totalfeeds |