Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 02-18-2017, 09:59 AM   #1
erkfuizfeuadjfjz
Member
erkfuizfeuadjfjz began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Feb 2017
Device: Sony PRS-T3
Recipe for Tweakers.net based on built in from Kovid Goyal

#!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
from __future__ import with_statement

''' Changelog
2012-04-27 DrMerry:
Added cover picture
removed some extra tags
'''

__license__ = 'GPL v3'
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
__docformat__ = 'restructuredtext en'

import re
from calibre.web.feeds.news import BasicNewsRecipe


class Tweakers(BasicNewsRecipe):
title = u'Tweakers.net'
__author__ = 'Kovid Goyal'
language = 'nl'
oldest_article = 4
max_articles_per_feed = 40
cover_url = 'http://tweakers.net/ext/launch/g/logo.gif'

keep_only_tags = [dict(name='div', attrs={'class': 'columnwrapper news'}),
dict(name='div', attrs={'class': 'article'})
]

remove_tags = [dict(name='div', attrs={'class': 'reacties'}),
{'id': ['utracker', 'socialButtons', 'b_ac']},
{'class': ['sidebar', 'advertorial']},
{'class': re.compile('nextPrevious')},
]
no_stylesheets = True
filter_regexps = [r'ads\.doubleclick\.net', r'ad\.doubleclick\.net']

feeds = [(u'Tweakers.net', u'http://tweakers.net/feeds/nieuws.xml')]

def preprocess_html(self, soup):
for a in soup.findAll('a', href=True, rel=True):
if a['rel'].startswith('imageview'):
a['src'] = a['href']
del a['href']
a.name = 'img'
for x in a.findAll(True):
x.extract()
return soup

def postprocess_html(self, soup, first):
for base in soup.findAll('base'):
base.extract()
return soup
erkfuizfeuadjfjz is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recipe for Het Laatste Nieuws (Belgian newspaper) based on built in recipe of Darko M erkfuizfeuadjfjz Recipes 0 02-17-2017 03:11 PM
Recipe voor De Tijd (Belgian newspaper) based on built in recipe of Darko Miletic erkfuizfeuadjfjz Recipes 0 02-17-2017 02:43 PM
Thank you Kovid Goyal! (Calibre) Canuck_in_Japan General Discussions 8 10-16-2013 08:23 AM
Alter built-in recipe for IP-based authentication barium Recipes 0 05-19-2012 02:20 AM
Modified Recipe Tweakers.net - need help roedi06 Recipes 4 01-17-2012 07:42 AM


All times are GMT -4. The time now is 08:52 PM.


MobileRead.com is a privately owned, operated and funded community.