mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix Business Week
This commit is contained in:
parent
bd58a50675
commit
f3d9c59cfb
@ -1,93 +1,105 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
__copyright__ = '2008 Kovid Goyal kovid@kovidgoyal.net, 2010 Darko Miletic <darko.miletic at gmail.com>'
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
businessweek.com
|
www.businessweek.com
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class BusinessWeek(BasicNewsRecipe):
|
class BusinessWeek(BasicNewsRecipe):
|
||||||
title = 'Business Week'
|
title = 'Business Week'
|
||||||
description = 'Business News, Stock Market and Financial Advice'
|
__author__ = 'Kovid Goyal and Darko Miletic'
|
||||||
__author__ = 'ChuckEggDotCom and Sujata Raman'
|
description = 'Read the latest international business news & stock market news. Get updated company profiles, financial advice, global economy and technology news.'
|
||||||
language = 'en'
|
publisher = 'Bloomberg L.P.'
|
||||||
|
category = 'Business, business news, stock market, stock market news, financial advice, company profiles, financial advice, global economy, technology news'
|
||||||
|
oldest_article = 7
|
||||||
|
max_articles_per_feed = 200
|
||||||
|
no_stylesheets = True
|
||||||
|
encoding = 'utf8'
|
||||||
|
use_embedded_content = False
|
||||||
|
language = 'en'
|
||||||
|
remove_empty_feeds = True
|
||||||
|
publication_type = 'magazine'
|
||||||
|
cover_url = 'http://images.businessweek.com/mz/covers/current_120x160.jpg'
|
||||||
|
masthead_url = 'http://assets.businessweek.com/images/bw-logo.png'
|
||||||
|
extra_css = """
|
||||||
|
body{font-family: Helvetica,Arial,sans-serif }
|
||||||
|
img{margin-bottom: 0.4em; display:block}
|
||||||
|
.tagline{color: gray; font-style: italic}
|
||||||
|
.photoCredit{font-size: small; color: gray}
|
||||||
|
"""
|
||||||
|
|
||||||
oldest_article = 7
|
conversion_options = {
|
||||||
max_articles_per_feed = 10
|
'comment' : description
|
||||||
no_stylesheets = True
|
, 'tags' : category
|
||||||
|
, 'publisher' : publisher
|
||||||
|
, 'language' : language
|
||||||
|
}
|
||||||
|
|
||||||
recursions = 1
|
remove_tags = [
|
||||||
match_regexps = [r'http://www.businessweek.com/.*_page_[1-9].*']
|
dict(attrs={'class':'inStory'})
|
||||||
extra_css = '''
|
,dict(name=['meta','link','iframe','base','embed','object','table','th','tr','td'])
|
||||||
h1{font-family :Arial,Helvetica,sans-serif; font-size:large;}
|
,dict(attrs={'id':['inset','videoDisplay']})
|
||||||
.news_story_title{font-family :Arial,Helvetica,sans-serif; font-size:large;font-weight:bold;}
|
]
|
||||||
h2{font-family :Arial,Helvetica,sans-serif; font-size:medium;color:#666666;}
|
keep_only_tags = [dict(name='div', attrs={'id':['story-body','storyBody','article_body','articleBody']})]
|
||||||
h3{text-transform:uppercase;font-family :Arial,Helvetica,sans-serif; font-size:large;font-weight:bold;}
|
remove_attributes = ['lang']
|
||||||
h4{font-family :Arial,Helvetica,sans-serif; font-size:small;font-weight:bold;}
|
match_regexps = [r'http://www.businessweek.com/.*_page_[1-9].*']
|
||||||
p{font-family :Arial,Helvetica,sans-serif; }
|
|
||||||
#lede600{font-size:x-small;}
|
|
||||||
#storybody{font-size:x-small;}
|
|
||||||
p{font-family :Arial,Helvetica,sans-serif;}
|
|
||||||
.strap{font-family :Arial,Helvetica,sans-serif; font-size:x-small; color:#064599;}
|
|
||||||
.byline{font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
|
|
||||||
.postedBy{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
|
||||||
.trackback{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
|
||||||
.date{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
|
||||||
.wrapper{font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
|
|
||||||
.photoCredit{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
|
||||||
.tagline{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
|
||||||
.pageCount{color:#666666;font-family :Arial,Helvetica,sans-serif; font-size:x-small;}
|
|
||||||
.note{font-family :Arial,Helvetica,sans-serif; font-size:small;color:#666666;font-style:italic;}
|
|
||||||
.highlight{font-family :Arial,Helvetica,sans-serif; font-size:small;background-color:#FFF200;}
|
|
||||||
.annotation{font-family :Arial,Helvetica,sans-serif; font-size:x-small;color:#666666;}
|
|
||||||
'''
|
|
||||||
|
|
||||||
remove_tags = [ dict(name='div', attrs={'id':["log","feedback","footer","secondarynav","secondnavbar","header","email","bw2-header","column2","wrapper-bw2-footer","wrapper-mgh-footer","inset","commentForm","commentDisplay","bwExtras","bw2-umbrella","readerComments","leg","rightcol"]}),
|
|
||||||
dict(name='div', attrs={'class':["menu",'sponsorbox smallertext',"TopNavTile","graybottom leaderboard"]}),
|
|
||||||
dict(name='img', alt ="News"),
|
|
||||||
dict(name='td', width ="1"),
|
|
||||||
]
|
|
||||||
|
|
||||||
feeds = [
|
|
||||||
(u'Top Stories', u'http://www.businessweek.com/topStories/rss/topStories.rss'),
|
feeds = [
|
||||||
(u'Top News', u'http://www.businessweek.com/rss/bwdaily.rss'),
|
(u'Top Stories', u'http://www.businessweek.com/topStories/rss/topStories.rss'),
|
||||||
(u'Asia', u'http://www.businessweek.com/rss/asia.rss'),
|
(u'Top News' , u'http://www.businessweek.com/rss/bwdaily.rss' ),
|
||||||
(u'Autos', u'http://www.businessweek.com/rss/autos/index.rss'),
|
(u'Asia', u'http://www.businessweek.com/rss/asia.rss'),
|
||||||
(u'Classic Cars', u'http://rss.businessweek.com/bw_rss/classiccars'),
|
(u'Autos', u'http://www.businessweek.com/rss/autos/index.rss'),
|
||||||
(u'Hybrids', u'http://rss.businessweek.com/bw_rss/hybrids'),
|
(u'Classic Cars', u'http://rss.businessweek.com/bw_rss/classiccars'),
|
||||||
(u'Europe', u'http://www.businessweek.com/rss/europe.rss'),
|
(u'Hybrids', u'http://rss.businessweek.com/bw_rss/hybrids'),
|
||||||
(u'Auto Reviews', u'http://rss.businessweek.com/bw_rss/autoreviews'),
|
(u'Europe', u'http://www.businessweek.com/rss/europe.rss'),
|
||||||
(u'Innovation & Design', u'http://www.businessweek.com/rss/innovate.rss'),
|
(u'Auto Reviews', u'http://rss.businessweek.com/bw_rss/autoreviews'),
|
||||||
(u'Architecture', u'http://www.businessweek.com/rss/architecture.rss'),
|
(u'Innovation & Design', u'http://www.businessweek.com/rss/innovate.rss'),
|
||||||
(u'Brand Equity', u'http://www.businessweek.com/rss/brandequity.rss'),
|
(u'Architecture', u'http://www.businessweek.com/rss/architecture.rss'),
|
||||||
(u'Auto Design', u'http://www.businessweek.com/rss/carbuff.rss'),
|
(u'Brand Equity', u'http://www.businessweek.com/rss/brandequity.rss'),
|
||||||
(u'Game Room', u'http://rss.businessweek.com/bw_rss/gameroom'),
|
(u'Auto Design', u'http://www.businessweek.com/rss/carbuff.rss'),
|
||||||
(u'Technology', u'http://www.businessweek.com/rss/technology.rss'),
|
(u'Game Room', u'http://rss.businessweek.com/bw_rss/gameroom'),
|
||||||
(u'Investing', u'http://rss.businessweek.com/bw_rss/investor'),
|
(u'Technology', u'http://www.businessweek.com/rss/technology.rss'),
|
||||||
(u'Small Business', u'http://www.businessweek.com/rss/smallbiz.rss'),
|
(u'Investing', u'http://rss.businessweek.com/bw_rss/investor'),
|
||||||
(u'Careers', u'http://rss.businessweek.com/bw_rss/careers'),
|
(u'Small Business', u'http://www.businessweek.com/rss/smallbiz.rss'),
|
||||||
(u'B-Schools', u'http://www.businessweek.com/rss/bschools.rss'),
|
(u'Careers', u'http://rss.businessweek.com/bw_rss/careers'),
|
||||||
(u'Magazine Selections', u'http://www.businessweek.com/rss/magazine.rss'),
|
(u'B-Schools', u'http://www.businessweek.com/rss/bschools.rss'),
|
||||||
(u'CEO Guide to Tech', u'http://www.businessweek.com/rss/ceo_guide_tech.rss'),
|
(u'Magazine Selections', u'http://www.businessweek.com/rss/magazine.rss'),
|
||||||
]
|
(u'CEO Guide to Tech', u'http://www.businessweek.com/rss/ceo_guide_tech.rss'),
|
||||||
|
]
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def get_article_url(self, article):
|
||||||
|
|
||||||
url = article.get('guid', None)
|
url = article.get('guid', None)
|
||||||
|
if 'podcasts' in url:
|
||||||
|
return None
|
||||||
|
if 'surveys' in url:
|
||||||
|
return None
|
||||||
|
if 'images' in url:
|
||||||
|
return None
|
||||||
|
if 'feedroom' in url:
|
||||||
|
return None
|
||||||
|
if '/magazine/toc/' in url:
|
||||||
|
return None
|
||||||
|
rurl, sep, rest = url.rpartition('?')
|
||||||
|
if rurl:
|
||||||
|
return rurl
|
||||||
|
return rest
|
||||||
|
|
||||||
if 'podcasts' in url or 'surveys' in url:
|
def print_version(self, url):
|
||||||
url = None
|
if '/news/' in url or '/blog/ in url':
|
||||||
|
return url
|
||||||
return url
|
if '/magazine' in url:
|
||||||
|
rurl = url.replace('http://www.businessweek.com/','http://www.businessweek.com/printer/')
|
||||||
def postprocess_html(self, soup, first):
|
else:
|
||||||
|
rurl = url.replace('http://www.businessweek.com/','http://www.businessweek.com/print/')
|
||||||
for tag in soup.findAll(name=['ul','li','table','td','tr','span']):
|
return rurl.replace('/investing/','/investor/')
|
||||||
tag.name = 'div'
|
|
||||||
for tag in soup.findAll(name= 'div',attrs={ 'id':'pageNav'}):
|
|
||||||
tag.extract()
|
|
||||||
return soup
|
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
for item in soup.findAll(style=True):
|
||||||
|
del item['style']
|
||||||
|
for alink in soup.findAll('a'):
|
||||||
|
if alink.string is not None:
|
||||||
|
tstr = alink.string
|
||||||
|
alink.replaceWith(tstr)
|
||||||
|
return soup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user