Quote:
Originally Posted by Aimylios
|
May I suggest to correct
Code:
publisher = 'Gazet van Antwerpen'
to
Code:
publisher = 'Mediahuis'
?
Using the example above I've come up with a recipe for another newspaper from the same publisher;
Het Nieuwsblad:
Code:
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1467571059(BasicNewsRecipe):
title = 'Het Nieuwsblad'
__author__ = 'Darko Miletic, Aimylios, oCkz7bJ_'
description = 'Het Nieuwsblad is goed voor u.'
publisher = 'Mediahuis'
category = 'news, politics, Belgium'
language = 'nl_BE'
oldest_article = 2
max_articles_per_feed = 100
no_stylesheets = True
use_embedded_content = False
remove_javascript = True
cover_url = 'http://www.lottocyclingcup.be/lc15/dendermedia/images/details/foto/partners_36/nieuwsblad_1_20160210_1242138359.jpg'
masthead_url = 'http://www.mediahuisconnect.be/uploads/media/5576fa0b83c38/nieuwsblad.svg'
#Source: http://www.nieuwsblad.be/rss
feeds = [
# Nieuws
('Snelnieuws', 'http://feeds.nieuwsblad.be/nieuws/snelnieuws'),
('Binnenland', 'http://feeds.nieuwsblad.be/nieuws/binnenland'),
('Buitenland', 'http://feeds.nieuwsblad.be/nieuwsblad/buitenland'),
# Economie
('Economie', 'http://feeds.nieuwsblad.be/economie/home'),
('Consument', 'http://feeds.nieuwsblad.be/economie/algemeen'),
('Bedrijven', 'http://feeds.nieuwsblad.be/economie/bedrijven'),
('Werk', 'http://feeds.nieuwsblad.be/economie/Werk'),
('Beurs', 'http://feeds.nieuwsblad.be/economie/beurs'),
# Regio
#('0123 Region1', 'http://www.nieuwsblad.be/rss.aspx?intro=1§ion=postcode&postcode=0123'),
#('3456 Region2', 'http://www.nieuwsblad.be/rss.aspx?intro=1§ion=postcode&postcode=3456'),
#('6789 Region3', 'http://www.nieuwsblad.be/rss.aspx?intro=1§ion=postcode&postcode=6789'),
# Sport
('Voetbal', 'http://feeds.nieuwsblad.be/nieuwsblad/sport/voetbal'),
('Wielrennen', 'http://feeds.nieuwsblad.be/nieuwsblad/sport/wielrennen'),
('Tennis', 'http://feeds.nieuwsblad.be/nieuwsblad/sport/tennis'),
('Autosport', 'http://feeds.nieuwsblad.be/nieuwsblad/sport/autosport'),
('Basketbal', 'http://feeds.nieuwsblad.be/nieuwsblad/sport/basketbal'),
('Volleybal', 'http://feeds.nieuwsblad.be/nieuwsblad/sport/volleybal'),
('Atletiek', 'http://feeds.nieuwsblad.be/nieuwsblad/sport/atletiek'),
# Extra
('Film', 'http://feeds.nieuwsblad.be/life/film'),
('Boek', 'http://feeds.nieuwsblad.be/life/boeken'),
('Muziek', 'http://feeds.nieuwsblad.be/life/muziek'),
('Podium', 'http://feeds.nieuwsblad.be/life/podium'),
('TV & Radio', 'http://feeds.nieuwsblad.be/life/tv'),
# She
('BV & Co', 'http://feeds.nieuwsblad.be/life/bv'),
('Mode & Design', 'http://feeds.nieuwsblad.be/life/mode'),
('Culinair', 'http://feeds.nieuwsblad.be/life/culinair'),
('Gezondheid', 'http://feeds.nieuwsblad.be/life/gezondheid'),
('Reizen', 'http://feeds.nieuwsblad.be/life/reizen'),
('Dieren', 'http://feeds.nieuwsblad.be/life/dieren'),
# Weblog
('Surfplank', 'http://nieuwsblad.typepad.com/surfplank/atom.xml'),
('Boeken', 'http://nieuwsblad.typepad.com/boeken/atom.xml'),
('Strips', 'http://nieuwsblad.typepad.com/strips/atom.xml'),
('DVD', 'http://nieuwsblad.typepad.com/dvd/atom.xml'),
('Dierendoktor', 'http://nieuwsblad.typepad.com/dierendokter/atom.xml'),
('Zapdog', 'http://nieuwsblad.typepad.com/zapdog/atom.xml'),
]
keep_only_tags = [
dict(name='header', attrs={'class':'article__header'}),
dict(name='footer', attrs={'class':'article__meta'}),
dict(name='div', attrs={'class':['article', 'article__body', 'slideshow__intro']}),
dict(name='figure', attrs={'class':'article__image'})
]
remove_tags = [
dict(name=['embed', 'object']),
dict(name='div', attrs={'class':['note NotePortrait', 'note']}),
dict(name='ul', attrs={'class':re.compile('article__share')}),
dict(name='div', attrs={'class':'slideshow__controls'}),
dict(name='a', attrs={'role':'button'}),
dict(name='figure', attrs={'class':re.compile('video')})
]
remove_attributes = ['width', 'height']
def preprocess_html(self, soup):
del soup.body['onload']
for item in soup.findAll(style=True):
del item['style']
return soup
Note: under "# regio"; only one out of the three postal codes I'm interested in seems to generate some content while the rss feeds do exist. Still need to figure out a solution for that. (The ones in the recipe above are fake placeholders.)