calibre/recipes/straitstimes.recipe
Kovid Goyal 567040ee1e Perform PEP8 compliance checks on the entire codebase
Some bits of PEP 8 are turned off via setup.cfg
2016-07-29 21:25:17 +05:30

62 lines
2.0 KiB
Plaintext

__license__ = 'GPL v3'
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
'''
www.straitstimes.com
'''
import re
from calibre.web.feeds.recipes import BasicNewsRecipe
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
}
preprocess_regexps = [
(re.compile(
r'<meta name="description" content="[^"]+"\s*/?>',
re.IGNORECASE | re.DOTALL),
lambda m:''),
(re.compile(r'<!--.+?-->', re.IGNORECASE | re.DOTALL),
lambda m: ''),
]
remove_tags = [
dict(name=['object', 'link', 'map', 'style']),
dict(attrs={'class': 'st2014-realted-links'}),
]
keep_only_tags = [dict(name='div', attrs={'class': 'story'})]
remove_tags_after = dict(name='div', attrs={'class': 'hr_thin'})
feeds = [
(u'Singapore', u'http://www.straitstimes.com/news/singapore/rss.xml'),
(u'Asia', u'http://www.straitstimes.com/news/asia/rss.xml'),
(u'Business', u'http://www.straitstimes.com/news/business/rss.xml'),
(u'Sport', u'http://www.straitstimes.com/news/sport/rss.xml'),
(u'World', u'http://www.straitstimes.com/news/world/rss.xml'),
(u'Lifestyle', u'http://www.straitstimes.com/news/lifestyle/rss.xml'),
(u'Digital Life', u'http://www.straitstimes.com/news/digital-life/rss.xml')
]
def preprocess_html(self, soup):
for a in soup.findAll('a', attrs={'class': 'thumb'}):
img = a.find('img')
if img is not None:
img['src'] = a['href']
return soup