From 9dc0e77a2556d0830f02b47e67e1f285641272aa Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 12 Apr 2011 14:20:05 -0600 Subject: [PATCH] Updated Vecernje Novosti. Fixes #759058 (Updated recipe for site Vecernje Novosti) --- recipes/novosti.recipe | 59 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/recipes/novosti.recipe b/recipes/novosti.recipe index d66e7d28b7..a0a573d7ba 100644 --- a/recipes/novosti.recipe +++ b/recipes/novosti.recipe @@ -1,6 +1,6 @@ __license__ = 'GPL v3' -__copyright__ = '2008-2010, Darko Miletic ' +__copyright__ = '2008-2011, Darko Miletic ' ''' novosti.rs ''' @@ -21,34 +21,71 @@ class Novosti(BasicNewsRecipe): encoding = 'utf-8' language = 'sr' publication_type = 'newspaper' + masthead_url = 'http://www.novosti.rs/images/basic/logo-print.png' extra_css = """ @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} .article_description,body{font-family: Arial,Helvetica,sans1,sans-serif} .author{font-size: small} .articleLead{font-size: large; font-weight: bold} + img{display: block; margin-bottom: 1em; margin-top: 1em} """ conversion_options = { - 'comment' : description - , 'tags' : category - , 'publisher' : publisher - , 'language' : language + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language + , 'pretty_print' : True } preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')] - keep_only_tags = [dict(attrs={'class':['articleTitle','author','articleLead','articleBody']})] - remove_tags = [dict(name=['embed','object','iframe','base','link','meta'])] - feeds = [(u'Vesti', u'http://www.novosti.rs/rss/rss-vesti')] + keep_only_tags = [dict(attrs={'class':['articleTitle','articleInfo','articleLead','singlePhoto fl','articleBody']})] + remove_tags = [ + dict(name=['embed','object','iframe','base','link','meta']) + ,dict(name='a', attrs={'class':'loadComments topCommentsLink'}) + ] + remove_attributes = ['lang','xmlns:fb'] + + feeds = [ + (u'Politika' , u'http://www.novosti.rs/rss/2-Sve%20vesti') + ,(u'Drustvo' , u'http://www.novosti.rs/rss/1-Sve%20vesti') + ,(u'Ekonomija' , u'http://www.novosti.rs/rss/3-Sve%20vesti') + ,(u'Hronika' , u'http://www.novosti.rs/rss/4-Sve%20vesti') + ,(u'Dosije' , u'http://www.novosti.rs/rss/5-Sve%20vesti') + ,(u'Reportaze' , u'http://www.novosti.rs/rss/6-Sve%20vesti') + ,(u'Tehnologije' , u'http://www.novosti.rs/rss/35-Sve%20vesti') + ,(u'Zanimljivosti', u'http://www.novosti.rs/rss/26-Sve%20vesti') + ,(u'Auto' , u'http://www.novosti.rs/rss/50-Sve%20vesti') + ,(u'Sport' , u'http://www.novosti.rs/rss/11|47|12|14|13-Sve%20vesti') + ,(u'Svet' , u'http://www.novosti.rs/rss/7-Sve%20vesti') + ,(u'Region' , u'http://www.novosti.rs/rss/8-Sve%20vesti') + ,(u'Dijaspora' , u'http://www.novosti.rs/rss/9-Sve%20vesti') + ,(u'Spektakl' , u'http://www.novosti.rs/rss/10-Sve%20vesti') + ,(u'Kultura' , u'http://www.novosti.rs/rss/31-Sve%20vesti') + ,(u'Srbija' , u'http://www.novosti.rs/rss/15-Sve%20vesti') + ,(u'Beograd' , u'http://www.novosti.rs/rss/16-Sve%20vesti') + ,(u'Zivot+' , u'http://www.novosti.rs/rss/24|33|34|25|20|18|32|19-Sve%20vesti') + ,(u'Turizam' , u'http://www.novosti.rs/rss/36-Sve%20vesti') + ] def preprocess_html(self, soup): for item in soup.findAll(style=True): del item['style'] - for item in soup.findAll('span', attrs={'class':'author'}): - item.name='p' + 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 = [] + else: + str = self.tag_to_string(item) + item.replaceWith(str) for item in soup.findAll('img'): if not item.has_key('alt'): item['alt'] = 'image' return soup -