mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Update Jakarta Post
This commit is contained in:
parent
35f2cc5048
commit
ce7c2fae68
@ -13,10 +13,8 @@ from calibre.web.feeds.news import BasicNewsRecipe
|
|||||||
|
|
||||||
class JakartaPost(BasicNewsRecipe):
|
class JakartaPost(BasicNewsRecipe):
|
||||||
title = u'Jakarta Post'
|
title = u'Jakarta Post'
|
||||||
masthead_url = 'http://www.thejakartapost.com/images/jakartapost_logo.jpg'
|
|
||||||
cover_url = 'http://www.thejakartapost.com/images/jakartapost_logo.jpg'
|
|
||||||
|
|
||||||
__author__ = u'Adrian Gunawan'
|
__author__ = u'Kovid Goyal'
|
||||||
description = u'Indonesian Newspaper in English from Jakarta Post Online Edition'
|
description = u'Indonesian Newspaper in English from Jakarta Post Online Edition'
|
||||||
category = 'breaking news, national, business, international, Indonesia'
|
category = 'breaking news, national, business, international, Indonesia'
|
||||||
language = 'en_ID'
|
language = 'en_ID'
|
||||||
@ -24,39 +22,40 @@ class JakartaPost(BasicNewsRecipe):
|
|||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
|
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
|
||||||
no_javascript = True
|
no_javascript = True
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
auto_cleanup = True
|
|
||||||
|
|
||||||
timefmt = ' [%A, %d %B, %Y]'
|
timefmt = ' [%A, %d %B, %Y]'
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
|
ignore_duplicate_articles = {'title', 'url'}
|
||||||
|
|
||||||
extra_css = '''
|
keep_only_tags = [
|
||||||
h1{font-family:Georgia,"Times New Roman",Times,serif; font-weight:bold; font-size:large;}
|
dict(name='h1'),
|
||||||
.cT-storyDetails{font-family:Arial,Helvetica,sans-serif; color:#666666;font-size:x-small;}
|
dict(attrs={'class':lambda x: x and 'byline' in x.split()}),
|
||||||
.articleBody{font-family:Arial,Helvetica,sans-serif; color:black;font-size:small;}
|
dict(attrs={'class':lambda x: x and 'span-13' in x.split()}),
|
||||||
.cT-imageLandscape{font-family:Arial,Helvetica,sans-serif; color:#333333 ;font-size:x-small;}
|
]
|
||||||
.source{font-family:Arial,Helvetica,sans-serif; color:#333333 ;font-size:xx-small;}
|
remove_tags_after = dict(attrs={'class':lambda x: x and 'span-12' in x.split()})
|
||||||
#content{font-family:Arial,Helvetica,sans-serif;font-size:x-small;}
|
|
||||||
.pageprint{font-family:Arial,Helvetica,sans-serif;font-size:small;}
|
|
||||||
#bylineDetails{font-family:Arial,Helvetica,sans-serif; color:#666666;font-size:x-small;}
|
|
||||||
.featurePic-wide{font-family:Arial,Helvetica,sans-serif;font-size:x-small;}
|
|
||||||
#idfeaturepic{font-family:Arial,Helvetica,sans-serif;font-size:x-small;}
|
|
||||||
h3{font-family:Georgia,"Times New Roman",Times,serif; font-size:small;}
|
|
||||||
h2{font-family:Georgia,"Times New Roman",Times,serif; font-size:small;}
|
|
||||||
h4{font-family:Georgia,"Times New Roman",Times,serif; font-size:small;}
|
|
||||||
h5{font-family:Georgia,"Times New Roman",Times,serif; font-size:small;}
|
|
||||||
body{font-family:Arial,Helvetica,sans-serif; font-size:x-small;}
|
|
||||||
'''
|
|
||||||
|
|
||||||
feeds = [
|
def parse_jp_section(self, url):
|
||||||
|
soup = self.index_to_soup(url)
|
||||||
|
for div in soup.findAll('div', attrs={'class':'story'}):
|
||||||
|
a = div.find('a', href=True)
|
||||||
|
url = a.get('href')
|
||||||
|
title = self.tag_to_string(a)
|
||||||
|
p = div.find('p')
|
||||||
|
desc = self.tag_to_string(p)
|
||||||
|
self.log('\t', title, ' at ', url)
|
||||||
|
yield {'title':title, 'url':url, 'description':desc}
|
||||||
|
|
||||||
(u'Breaking News', u'http://www.thejakartapost.com/breaking/feed'),
|
def parse_index(self):
|
||||||
(u'National', u'http://www.thejakartapost.com/channel/national/feed'),
|
ans = []
|
||||||
(u'Archipelago', u'http://www.thejakartapost.com/channel/archipelago/feed'),
|
for sec in ('editors_choice channel/headlines channel/business channel/national channel/archipelago'
|
||||||
(u'Business', u'http://www.thejakartapost.com/channel/business/feed'),
|
' channel/jakarta channel/world channel/sports').split():
|
||||||
(u'Jakarta', u'http://www.thejakartapost.com/channel/jakarta/feed'),
|
title = (sec.partition('/')[2] or sec).replace('_', ' ').capitalize()
|
||||||
(u'World', u'http://www.thejakartapost.com/channel/world/feed'),
|
articles = list(self.parse_jp_section('http://www.thejakartapost.com/' + sec))
|
||||||
(u'Sports', u'http://www.thejakartapost.com/channel/sports/feed'),
|
self.log('Found section:', title)
|
||||||
]
|
if articles:
|
||||||
|
ans.append((title, articles))
|
||||||
|
if self.test and len(ans) >= self.test[0]:
|
||||||
|
break
|
||||||
|
return ans
|
||||||
|
Loading…
x
Reference in New Issue
Block a user