calibre/recipes/deutsche_welle_es.recipe
Kovid Goyal 567040ee1e Perform PEP8 compliance checks on the entire codebase
Some bits of PEP 8 are turned off via setup.cfg
2016-07-29 21:25:17 +05:30

77 lines
2.6 KiB
Python

#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
__license__ = 'GPL v3'
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
'''
Deutsche Welle (español) - dw.com/es
'''
import re
from calibre.web.feeds.news import BasicNewsRecipe
class DeutscheWelle_es(BasicNewsRecipe):
title = 'Deutsche Welle'
__author__ = 'Darko Miletic'
description = 'Noticias desde Alemania y mundo'
publisher = 'Deutsche Welle'
language = 'es'
oldest_article = 2
max_articles_per_feed = 50
no_stylesheets = True
remove_javascript = True
remove_empty_feeds = True
ignore_duplicate_articles = {'title', 'url'}
feeds = [
('Titulares', 'http://rss.dw-world.de/rdf/rss-sp-top'),
('Noticias de Alemania', 'http://rss.dw-world.de/rdf/rss-sp-ale'),
('Internacionales', 'http://rss.dw-world.de/rdf/rss-sp-inter'),
('Cultura', 'http://rss.dw-world.de/rdf/rss-sp-cul'),
('Ciencia y Tecnología', 'http://rss.dw-world.de/rdf/rss-sp-cyt'),
('Economía', 'http://rss.dw-world.de/rdf/rss-sp-eco'),
('La prensa opina', 'http://rss.dw-world.de/rdf/rss-sp-press'),
('Ecología', 'http://rss.dw-world.de/rdf/rss-sp-ecol'),
('Futbol alemán', 'http://rss.dw-world.de/rdf/rss-sp-fut'),
('Conozca Alemania', 'http://rss.dw-world.de/rdf/rss-sp-con')
]
keep_only_tags = [
dict(name='div', attrs={'class': 'col3'})
]
remove_tags_after = [
dict(name='div', attrs={'class': 'group'})
]
remove_tags = [
dict(name='div', attrs={'class': 'col1'}),
dict(name='div', attrs={'class': re.compile('gallery')}),
dict(name='div', attrs={'class': re.compile('audio')}),
dict(name='div', attrs={'class': re.compile('video')})
]
remove_attributes = ['height', 'width',
'onclick', 'border', 'lang', 'link']
extra_css = '''
h1 {font-size: 1.6em; margin-top: 0em}
.artikel {font-size: 1em; text-transform: uppercase; margin: 0em}
'''
def preprocess_html(self, soup):
# convert local hyperlinks
for a in soup.findAll('a', href=True):
if a['href'].startswith('/'):
a['href'] = 'http://www.dw.com' + a['href']
elif a['href'].startswith('#'):
del a['href']
# remove all style attributes with an effect on font size
for item in soup.findAll(attrs={'style': re.compile('font-size')}):
del item['style']
return soup