calibre/recipes/straitstimes.recipe
2021-04-02 13:09:46 +05:30

62 lines
2.5 KiB
Plaintext

__license__ = 'GPL v3'
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
'''
www.straitstimes.com
'''
from calibre.web.feeds.recipes import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
class StraitsTimes(BasicNewsRecipe):
title = 'The Straits Times'
__author__ = 'Darko Miletic'
description = 'Singapore newspaper'
oldest_article = 2
max_articles_per_feed = 100
no_stylesheets = True
use_embedded_content = False
encoding = 'utf-8'
publisher = 'Singapore Press Holdings Ltd.'
category = 'news, politics, singapore, asia'
language = 'en_SG'
conversion_options = {
'comments': description, 'tags': category, 'language': language, 'publisher': publisher
}
keep_only_tags = [
classes('node-header node-subheadline group-byline-info group-updated-timestamp group-image-frame field-name-body')
]
remove_tags = [
classes('st_telegram_boilerplate'),
dict(name='source'),
]
feeds = [
(u'Top of the News' , u'http://www.straitstimes.com/print/top-of-the-news/rss.xml')
,(u'World' , u'http://www.straitstimes.com/print/world/rss.xml')
,(u'Home' , u'http://www.straitstimes.com/print/home/rss.xml')
,(u'Business' , u'http://www.straitstimes.com/print/business/rss.xml')
,(u'Life' , u'http://www.straitstimes.com/print/life/rss.xml')
,(u'Science' , u'http://www.straitstimes.com/print/science/rss.xml')
,(u'Digital' , u'http://www.straitstimes.com/print/digital/rss.xml')
,(u'Insight' , u'http://www.straitstimes.com/print/insight/rss.xml')
,(u'Opinion' , u'http://www.straitstimes.com/print/opinion/rss.xml')
,(u'Forum' , u'http://www.straitstimes.com/print/forum/rss.xml')
,(u'Big Picture' , u'http://www.straitstimes.com/print/big-picture/rss.xml')
,(u'Community' , u'http://www.straitstimes.com/print/community/rss.xml')
,(u'Education' , u'http://www.straitstimes.com/print/education/rss.xml')
]
def preprocess_html(self, soup):
for img in soup.findAll('img', srcset=True):
img['src'] = img['srcset'].partition(' ')[0]
img['srcset'] = ''
return soup