mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Update The Onion
This commit is contained in:
parent
78924144aa
commit
6bd12a4450
@ -36,47 +36,21 @@ class TheOnion(BasicNewsRecipe):
|
|||||||
, 'publisher': publisher
|
, 'publisher': publisher
|
||||||
, 'language' : language
|
, 'language' : language
|
||||||
}
|
}
|
||||||
|
keep_only_tags = [dict(name='article', attrs={'class':'full-article'})]
|
||||||
keep_only_tags = [
|
|
||||||
dict(name='h2', attrs={'class':['section_title','title']})
|
|
||||||
,dict(attrs={'class':['main_image','meta','article_photo_lead','article_body']})
|
|
||||||
,dict(attrs={'id':['entries']})
|
|
||||||
]
|
|
||||||
remove_attributes=['lang','rel']
|
|
||||||
remove_tags_after = dict(attrs={'class':['article_body','feature_content']})
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name=['object','link','iframe','base','meta'])
|
dict(name=['nav', 'aside', 'section', 'meta']),
|
||||||
,dict(name='div', attrs={'class':['toolbar_side','graphical_feature','toolbar_bottom']})
|
{'attrs':{'class':lambda x: x and ('share-tools' in x or 'ad-zone' in x)}},
|
||||||
,dict(name='div', attrs={'id':['recent_slider','sidebar','pagination','related_media']})
|
]
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'Daily' , u'http://feeds.theonion.com/theonion/daily' )
|
(u'Daily' , u'http://feeds.theonion.com/theonion/daily' )
|
||||||
,(u'Sports' , u'http://feeds.theonion.com/theonion/sports' )
|
,(u'Sports' , u'http://feeds.theonion.com/theonion/sports' )
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def preprocess_html(self, soup, *args):
|
||||||
artl = BasicNewsRecipe.get_article_url(self, article)
|
for img in soup.findAll('img', attrs={'data-src':True}):
|
||||||
if artl.startswith('http://www.theonion.com/audio/'):
|
if img['data-src']:
|
||||||
artl = None
|
img['src'] = img['data-src']
|
||||||
return artl
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
|
||||||
for item in soup.findAll(style=True):
|
|
||||||
del item['style']
|
|
||||||
for item in soup.findAll('a'):
|
|
||||||
limg = item.find('img')
|
|
||||||
if item.string is not None:
|
|
||||||
str = item.string
|
|
||||||
item.replaceWith(str)
|
|
||||||
else:
|
|
||||||
if limg:
|
|
||||||
item.name = 'div'
|
|
||||||
item.attrs = []
|
|
||||||
if not limg.has_key('alt'):
|
|
||||||
limg['alt'] = 'image'
|
|
||||||
else:
|
|
||||||
str = self.tag_to_string(item)
|
|
||||||
item.replaceWith(str)
|
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user