mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update msnbc.com
This commit is contained in:
parent
0ebb813f8b
commit
0de1cf661d
@ -16,44 +16,18 @@ class MsNBC(BasicNewsRecipe):
|
|||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
encoding = 'utf8'
|
encoding = 'utf8'
|
||||||
publisher = 'msnbc.com'
|
publisher = 'msnbc.com'
|
||||||
category = 'news, USA, world'
|
|
||||||
language = 'en'
|
language = 'en'
|
||||||
extra_css = """
|
|
||||||
body{ font-family: Georgia,Times,serif }
|
|
||||||
.hide{display: none}
|
|
||||||
.caption{font-family: Arial,sans-serif; font-size: x-small}
|
|
||||||
.entry-summary{font-family: Arial,sans-serif}
|
|
||||||
.copyright{font-size: 0.95em; font-style: italic}
|
|
||||||
.source-org{font-size: small; font-family: Arial,sans-serif}
|
|
||||||
img{display: block; margin-bottom: 0.5em}
|
|
||||||
span.byline{display: none}
|
|
||||||
"""
|
|
||||||
|
|
||||||
conversion_options = {
|
|
||||||
'comments' : description
|
|
||||||
,'tags' : category
|
|
||||||
,'language' : language
|
|
||||||
,'publisher': publisher
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_tags_before = dict(name='h1', attrs={'id':'headline'})
|
|
||||||
remove_tags_after = dict(name='span', attrs={'class':['copyright','Linear copyright']})
|
|
||||||
keep_only_tags=[
|
keep_only_tags=[
|
||||||
dict(attrs={'id':['headline','deck','byline','source','intelliTXT']})
|
dict(itemprop='headline'),
|
||||||
,dict(attrs={'class':['gl_headline','articleText','drawer-content Linear','v-center3','byline','textBodyBlack']})
|
dict(attrs={'class':lambda x: x and set(x.split()).intersection({'byline_article', 'article_main'})}),
|
||||||
]
|
]
|
||||||
remove_attributes=['property','lang','rel','xmlns:fb','xmlns:v','xmlns:dc','xmlns:dcmitype','xmlns:og','xmlns:media','xmlns:vcard','typeof','itemscope','itemtype','itemprop','about','type','size','width','height','onreadystatechange','data','border','hspace','vspace']
|
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name=['iframe','object','link','embed','meta','table'])
|
dict(name=['iframe', 'button', 'meta', 'link']),
|
||||||
,dict(name='span', attrs={'class':['copyright','Linear copyright']})
|
dict(attrs={'class':lambda x: x and set(x.split()).intersection({'widget_video', 'ad-container'})}),
|
||||||
,dict(name='div', attrs={'class':'social'})
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'US News' , u'http://rss.msnbc.msn.com/id/3032524/device/rss/rss.xml')
|
(u'US News' , u'http://rss.msnbc.msn.com/id/3032524/device/rss/rss.xml')
|
||||||
,(u'World News' , u'http://rss.msnbc.msn.com/id/3032506/device/rss/rss.xml' )
|
|
||||||
,(u'Politics' , u'http://rss.msnbc.msn.com/id/3032552/device/rss/rss.xml')
|
,(u'Politics' , u'http://rss.msnbc.msn.com/id/3032552/device/rss/rss.xml')
|
||||||
,(u'Business' , u'http://rss.msnbc.msn.com/id/3032071/device/rss/rss.xml')
|
,(u'Business' , u'http://rss.msnbc.msn.com/id/3032071/device/rss/rss.xml')
|
||||||
,(u'Sports' , u'http://rss.nbcsports.msnbc.com/id/3032112/device/rss/rss.xml')
|
,(u'Sports' , u'http://rss.nbcsports.msnbc.com/id/3032112/device/rss/rss.xml')
|
||||||
@ -62,26 +36,10 @@ class MsNBC(BasicNewsRecipe):
|
|||||||
,(u'Tech & Science', u'http://rss.msnbc.msn.com/id/3032117/device/rss/rss.xml')
|
,(u'Tech & Science', u'http://rss.msnbc.msn.com/id/3032117/device/rss/rss.xml')
|
||||||
]
|
]
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def get_article_url(self, article):
|
||||||
for item in soup.body.findAll('html'):
|
return article.get('guid')
|
||||||
item.name='div'
|
|
||||||
for item in soup.body.findAll('div'):
|
|
||||||
if item.has_key('id') and item['id'].startswith('vine-'):
|
|
||||||
item.extract()
|
|
||||||
if item.has_key('class') and ( item['class'].startswith('ad') or item['class'].startswith('vine')):
|
|
||||||
item.extract()
|
|
||||||
for item in soup.body.findAll('img'):
|
|
||||||
if not item.has_key('alt'):
|
|
||||||
item['alt'] = 'image'
|
|
||||||
for item in soup.body.findAll('ol'):
|
|
||||||
if item.has_key('class') and item['class'].startswith('grid'):
|
|
||||||
item.extract()
|
|
||||||
for item in soup.body.findAll('span'):
|
|
||||||
if ( item.has_key('id') and item['id'].startswith('byLine') and item.string is None) or ( item.has_key('class') and item['class'].startswith('inline') ):
|
|
||||||
item.extract()
|
|
||||||
for alink in soup.findAll('a'):
|
|
||||||
if alink.string is not None:
|
|
||||||
tstr = alink.string
|
|
||||||
alink.replaceWith(tstr)
|
|
||||||
return soup
|
|
||||||
|
|
||||||
|
def preprocess_html(self, soup):
|
||||||
|
for img in soup.findAll('img', attrs={'data-original':True}):
|
||||||
|
img['src'] = img['data-original']
|
||||||
|
return soup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user