2
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
8
from calibre.web.feeds.news import BasicNewsRecipe
10
class SCMP(BasicNewsRecipe):
11
title = 'South China Morning Post'
13
description = "SCMP.com, Hong Kong's premier online English daily provides exclusive up-to-date news, audio video news, podcasts, RSS Feeds, Blogs, breaking news, top stories, award winning news and analysis on Hong Kong and China."
14
publisher = 'South China Morning Post Publishers Ltd.'
15
category = 'SCMP, Online news, Hong Kong News, China news, Business news, English newspaper, daily newspaper, Lifestyle news, Sport news, Audio Video news, Asia news, World news, economy news, investor relations news, RSS Feeds'
18
max_articles_per_feed = 200
21
use_embedded_content = False
23
remove_empty_feeds = True
24
needs_subscription = True
25
publication_type = 'newspaper'
26
masthead_url = 'http://www.scmp.com/images/logo_scmp_home.gif'
27
extra_css = ' body{font-family: Arial,Helvetica,sans-serif } '
29
conversion_options = {
30
'comment' : description
32
, 'publisher' : publisher
33
, 'language' : language
36
def get_browser(self):
37
br = BasicNewsRecipe.get_browser()
38
#br.set_debug_http(True)
39
#br.set_debug_responses(True)
40
#br.set_debug_redirects(True)
41
if self.username is not None and self.password is not None:
42
br.open('http://www.scmp.com/portal/site/SCMP/')
43
br.select_form(name='loginForm')
44
br['Login' ] = self.username
45
br['Password'] = self.password
49
remove_attributes=['width','height','border']
52
dict(attrs={'id':['ART','photoBox']})
53
,dict(attrs={'class':['article_label','article_byline','article_body']})
56
preprocess_regexps = [
57
(re.compile(r'<P><table((?!<table).)*class="embscreen"((?!</table>).)*</table>', re.DOTALL|re.IGNORECASE),
62
(u'Business' , u'http://www.scmp.com/rss/business.xml' )
63
,(u'Hong Kong' , u'http://www.scmp.com/rss/hong_kong.xml' )
64
,(u'China' , u'http://www.scmp.com/rss/china.xml' )
65
,(u'Asia & World' , u'http://www.scmp.com/rss/news_asia_world.xml')
66
,(u'Opinion' , u'http://www.scmp.com/rss/opinion.xml' )
67
,(u'LifeSTYLE' , u'http://www.scmp.com/rss/lifestyle.xml' )
68
,(u'Sport' , u'http://www.scmp.com/rss/sport.xml' )
71
def print_version(self, url):
72
rpart, sep, rest = url.rpartition('&')
73
return rpart #+ sep + urllib.quote_plus(rest)
75
def preprocess_html(self, soup):
76
for item in soup.findAll(style=True):
78
items = soup.findAll(src="/images/label_icon.gif")
79
[item.extract() for item in items]
80
return self.adeify_images(soup)