diff --git a/resources/recipes/nspm.recipe b/resources/recipes/nspm.recipe index 636f34aac2..c00e472636 100644 --- a/resources/recipes/nspm.recipe +++ b/resources/recipes/nspm.recipe @@ -6,6 +6,7 @@ nspm.rs import re from calibre.web.feeds.news import BasicNewsRecipe +from calibre.ebooks.BeautifulSoup import Tag class Nspm(BasicNewsRecipe): title = 'Nova srpska politicka misao' @@ -22,22 +23,24 @@ class Nspm(BasicNewsRecipe): language = 'sr' publication_type = 'magazine' masthead_url = 'http://www.nspm.rs/templates/jsn_epic_pro/images/logol.jpg' - extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} body{text-align: justify; font-family: serif1, serif} .article_description{font-family: sans1, sans-serif}' + extra_css = ' @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} body{font-family: "Times New Roman", serif1, serif} .article_description{font-family: Arial, sans1, sans-serif} img{margin-top:0.5em; margin-bottom: 0.7em} .author{color: #990000; font-weight: bold} .author,.createdate{font-size: 0.9em} img{margin-top:0.5em; margin-bottom: 0.7em} ' conversion_options = { - 'comment' : description - , 'tags' : category - , 'publisher' : publisher - , 'language' : language - , 'linearize_tables' : True + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language } preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')] remove_tags = [ - dict(name=['link','object','embed']) + dict(name=['link','object','embed','script','meta']) ,dict(name='td', attrs={'class':'buttonheading'}) ] - remove_tags_after = dict(attrs={'class':'article_separator'}) + keep_only_tags = [ + dict(attrs={'class':['contentpagetitle','author','createdate']}) + ,dict(name='p') + ] remove_attributes = ['width','height'] def get_browser(self): @@ -53,4 +56,17 @@ class Nspm(BasicNewsRecipe): def preprocess_html(self, soup): for item in soup.body.findAll(style=True): del item['style'] - return self.adeify_images(soup) + att = soup.find('a',attrs={'class':'contentpagetitle'}) + if att: + att.name = 'h1'; + del att['href'] + att2 = soup.find('td') + if att2: + att2.name = 'p'; + del att['valign'] + for pt in soup.findAll('img'): + brtag = Tag(soup,'br') + brtag2 = Tag(soup,'br') + pt.append(brtag) + pt.append(brtag2) + return soup diff --git a/resources/recipes/pescanik.recipe b/resources/recipes/pescanik.recipe index 3ab9c24de3..c07434535f 100644 --- a/resources/recipes/pescanik.recipe +++ b/resources/recipes/pescanik.recipe @@ -6,6 +6,7 @@ pescanik.net import re from calibre.web.feeds.news import BasicNewsRecipe +from calibre.ebooks.BeautifulSoup import Tag class Pescanik(BasicNewsRecipe): title = 'Pescanik' @@ -13,32 +14,34 @@ class Pescanik(BasicNewsRecipe): description = 'Pescanik' publisher = 'Pescanik' category = 'news, politics, Serbia' - oldest_article = 5 + oldest_article = 10 max_articles_per_feed = 100 no_stylesheets = True use_embedded_content = False encoding = 'utf-8' language = 'sr' publication_type = 'newsportal' - extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} .article_description,body{font-family: Arial,"Lucida Grande",Tahoma,Verdana,sans1,sans-serif} .contentheading{font-size: x-large; font-weight: bold} .small{font-size: small} .createdate{font-size: x-small; font-weight: bold}' + extra_css = ' @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} .article_description,body{font-family: Arial,"Lucida Grande",Tahoma,Verdana,sans1,sans-serif} .contentheading{font-size: x-large; font-weight: bold} .small{font-size: small} .createdate{font-size: x-small; font-weight: bold} ' conversion_options = { - 'comment' : description - , 'tags' : category - , 'publisher' : publisher - , 'language' : language - , 'linearize_tables' : True + 'comment' : description + , 'tags' : category + , 'publisher' : publisher + , 'language' : language } preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')] + + remove_attributes = ['valign','colspan','width','height','align','alt'] + + remove_tags = [dict(name=['object','link','meta','script'])] - remove_tags = [ - dict(name='td' , attrs={'class':'buttonheading'}) - ,dict(name='span', attrs={'class':'article_seperator'}) - ,dict(name=['object','link','h4','ul']) - ] - + keep_only_tags = [ + dict(attrs={'class':['contentheading','small','createdate']}) + ,dict(name='td', attrs={'valign':'top','colspan':'2'}) + ] + feeds = [(u'Pescanik Online', u'http://www.pescanik.net/index.php?option=com_rd_rss&id=12')] def print_version(self, url): @@ -46,4 +49,12 @@ class Pescanik(BasicNewsRecipe): return nurl + '&pop=1&page=0' def preprocess_html(self, soup): - return self.adeify_images(soup) + st = soup.findAll('td') + for it in st: + it.name='p' + for pt in soup.findAll('img'): + brtag = Tag(soup,'br') + brtag2 = Tag(soup,'br') + pt.append(brtag) + pt.append(brtag2) + return soup