| 1 |
import re |
| 2 |
|
| 3 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 4 |
|
| 5 |
|
| 6 |
class ADRecipe(BasicNewsRecipe): |
| 7 |
__license__ = 'GPL v3' |
| 8 |
__author__ = 'kwetal' |
| 9 |
language = 'nl' |
| 10 |
country = 'NL' |
| 11 |
version = 1 |
| 12 |
|
| 13 |
title = 'AD' |
| 14 |
publisher = 'de Persgroep Publishing Nederland NV' |
| 15 |
category = 'News, Sports, the Netherlands' |
| 16 |
description = 'News and Sports from the Netherlands' |
| 17 |
|
| 18 |
oldest_article = 1.2 |
| 19 |
max_articles_per_feed = 100 |
| 20 |
use_embedded_content = False |
| 21 |
|
| 22 |
remove_empty_feeds = True |
| 23 |
no_stylesheets = True |
| 24 |
remove_javascript = True |
| 25 |
|
| 26 |
keep_only_tags = [] |
| 27 |
keep_only_tags.append(dict(name='div', attrs={'id': 'art_box2'})) |
| 28 |
keep_only_tags.append(dict(name='p', attrs={'class': 'gen_footnote3'})) |
| 29 |
|
| 30 |
remove_tags = [] |
| 31 |
remove_tags.append(dict(name='div', attrs={'class': 'gen_clear'})) |
| 32 |
remove_tags.append(dict(name='div', attrs={'class': re.compile(r'gen_spacer.*')})) |
| 33 |
|
| 34 |
remove_attributes = ['style'] |
| 35 |
|
| 36 |
# feeds from |
| 37 |
# http://ad.nl/ad/nl/1401/home/integration/nmc/frameset/ad_footer/rssFeeds.dhtml |
| 38 |
feeds = [] |
| 39 |
feeds.append(('Binnenland', 'http://www.ad.nl/nieuws/binnenland/rss.xml')) |
| 40 |
feeds.append(('Buitenland', 'http://www.ad.nl/nieuws/buitenland/rss.xml')) |
| 41 |
feeds.append(('Bizar', 'http://www.ad.nl/nieuws/bizar/rss.xml')) |
| 42 |
feeds.append(('Gezondheid & Wetenschap', 'http://www.ad.nl/nieuws/gezondheidwetenschap/rss.xml')) |
| 43 |
feeds.append(('Economie', 'http://www.ad.nl/nieuws/economie/rss.xml')) |
| 44 |
feeds.append(('Nederlands Voetbal', 'http://www.ad.nl/sportwereld/nederlandsvoetbal/rss.xml')) |
| 45 |
feeds.append(('Buitenlands Voetbal', 'http://www.ad.nl/sportwereld/buitenlandsvoetbal/rss.xml')) |
| 46 |
feeds.append(('Champions League/Europa League', 'http://www.ad.nl/sportwereld/championsleagueeuropaleague/rss.xml')) |
| 47 |
feeds.append(('Wielrennen', 'http://www.ad.nl/sportwereld/wielrennen/rss.xml')) |
| 48 |
feeds.append(('Tennis', 'http://www.ad.nl/sportwereld/tennis/rss.xml')) |
| 49 |
feeds.append(('Formule 1', 'http://www.ad.nl/sportwereld/formule1/rss.xml')) |
| 50 |
feeds.append(('Meer Sport', 'http://www.ad.nl/sportwereld/meersport/rss.xml')) |
| 51 |
feeds.append(('Celebs', 'http://www.ad.nl/showbizz/celebs/rss.xml')) |
| 52 |
feeds.append(('Film', 'http://www.ad.nl/showbizz/film/rss.xml')) |
| 53 |
feeds.append(('Muziek', 'http://www.ad.nl/showbizz/muziek/rss.xml')) |
| 54 |
feeds.append(('TV', 'http://www.ad.nl/showbizz/tv/rss.xml')) |
| 55 |
feeds.append(('Kunst & Literatuur', 'http://www.ad.nl/showbizz/kunstenliteratuur/rss.xml')) |
| 56 |
feeds.append(('Jouw Wereld', 'http://www.ad.nl/you/rss.xml')) |
| 57 |
feeds.append(('Consument', 'http://www.ad.nl/consument/rss.xml')) |
| 58 |
feeds.append(('Autowereld', 'http://www.ad.nl/autowereld/rss.xml')) |
| 59 |
feeds.append(('Reiswereld', 'http://www.ad.nl/reiswereld/rss.xml')) |
| 60 |
feeds.append(('Internet', 'http://www.ad.nl/digitaal/internet/rss.xml')) |
| 61 |
feeds.append(('Games', 'http://www.ad.nl/digitaal/games/rss.xml')) |
| 62 |
feeds.append(('Multimedia', 'http://www.ad.nl/digitaal/multimedia/rss.xml')) |
| 63 |
feeds.append(('Planet Watch', 'http://www.ad.nl/planetwatch/rss.xml')) |
| 64 |
|
| 65 |
extra_css = ''' |
| 66 |
body {font-family: verdana, arial, helvetica, geneva, sans-serif;} |
| 67 |
div.captionEmbeddedMasterObject {font-size: x-small; font-style: italic; color: #696969;} |
| 68 |
.gen_footnote3 {font-size: small; color: #666666; margin-top: 0.6em;} |
| 69 |
''' |
| 70 |
|
| 71 |
conversion_options = {'comments': description, 'tags': category, 'language': 'en', 'publisher': publisher} |
| 72 |
|
| 73 |
def print_version(self, url): |
| 74 |
parts = url.split('/') |
| 75 |
print_url = 'http://' + '/'.join([ |
| 76 |
parts[2], |
| 77 |
parts[3], |
| 78 |
parts[4], |
| 79 |
parts[5], |
| 80 |
parts[10], |
| 81 |
parts[7], |
| 82 |
'print', |
| 83 |
parts[8], |
| 84 |
parts[9], |
| 85 |
parts[13], |
| 86 |
]) |
| 87 |
|
| 88 |
return print_url |
| 89 |
|
| 90 |
def preprocess_html(self, soup): |
| 91 |
for br in soup.findAll('br'): |
| 92 |
prev = br.findPreviousSibling(True) |
| 93 |
if hasattr(prev, 'name') and prev.name == 'br': |
| 94 |
next = br.findNextSibling(True) |
| 95 |
if hasattr(next, 'name') and next.name == 'br': |
| 96 |
br.extract() |
| 97 |
|
| 98 |
return soup |