From 4bcede833d3eb288d5ae2118f34105b814b5fa04 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 25 Aug 2009 18:26:49 -0600 Subject: [PATCH] New recipe for The Edge Singapore by Darko Miletic --- src/calibre/web/feeds/recipes/__init__.py | 2 +- .../feeds/recipes/recipe_thedgesingapore.py | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/calibre/web/feeds/recipes/recipe_thedgesingapore.py diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 7f9723063c..2892e88379 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -55,7 +55,7 @@ recipe_modules = ['recipe_' + r for r in ( 'eltiempo_hn', 'slate', 'tnxm', 'bbcvietnamese', 'vnexpress', 'volksrant', 'theeconomictimes_india', 'ourdailybread', 'monitor', 'republika', 'beta', 'beta_en', 'glasjavnosti', - 'esquire', 'livemint', + 'esquire', 'livemint', 'thedgesingapore', )] diff --git a/src/calibre/web/feeds/recipes/recipe_thedgesingapore.py b/src/calibre/web/feeds/recipes/recipe_thedgesingapore.py new file mode 100644 index 0000000000..248255bee5 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_thedgesingapore.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2009, Darko Miletic ' +''' +www.livemint.com +''' + +from calibre.web.feeds.news import BasicNewsRecipe + +class Edgesingapore(BasicNewsRecipe): + title = 'The Edge Singapore' + __author__ = 'Darko Miletic' + description = 'Financial news from Singapore' + publisher = 'The Edge Singapore' + category = 'news, finances, singapore' + language = _('English') + lang = 'en' + oldest_article = 15 + max_articles_per_feed = 100 + no_stylesheets = True + encoding = 'utf-8' + use_embedded_content = False + extra_css = ' .contentheading{font-size: x-large} .small{font-size: small} .createdate{font-size: small; font-weight: bold} ' + + + conversion_options = { + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'author' : publisher + , 'language' : lang + , 'pretty_print' : True + , 'linearize_tables' : True + } + + + remove_tags = [ + dict(name=['object','link','embed','form','iframe']) + ,dict(name='div',attrs={'id':'toolbar-article'}) + ,dict(name='div',attrs={'class':'backtotop'}) + ,dict(name='img',attrs={'alt':'Print'}) + ] + + remove_tags_after = dict(name='div',attrs={'class':'backtotop'}) + + feeds = [(u'Articles', u'http://feeds.feedburner.com/edgesg')] + + def print_version(self, url): + return url + '?tmpl=component&print=1' + + def preprocess_html(self, soup): + attribs = [ 'style','font','valign' + ,'colspan','width','height' + ,'rowspan','summary','align' + ,'cellspacing','cellpadding' + ,'frames','rules','border' + ] + for item in soup.body.findAll(name=['table','td','tr','th','caption','thead','tfoot','tbody','colgroup','col']): + item.name = 'div' + for attrib in attribs: + if item.has_key(attrib): + del item[attrib] + return self.adeify_images(soup)