diff --git a/resources/recipes/houston_chronicle.recipe b/resources/recipes/houston_chronicle.recipe index 77e35dfc0c..3ec1abbf0f 100644 --- a/resources/recipes/houston_chronicle.recipe +++ b/resources/recipes/houston_chronicle.recipe @@ -1,17 +1,41 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai from calibre.web.feeds.news import BasicNewsRecipe class HoustonChronicle(BasicNewsRecipe): title = u'The Houston Chronicle' description = 'News from Houston, Texas' - __author__ = 'Kovid Goyal' + __author__ = 'Kovid Goyal and Sujata Raman' language = 'en' timefmt = ' [%a, %d %b, %Y]' no_stylesheets = True - keep_only_tags = [dict(id=['story-head', 'story'])] - remove_tags = [dict(id=['share-module', 'resource-box', - 'resource-box-header'])] + keep_only_tags = [ + dict(id=['story-head', 'story']) + ] + + remove_tags = [ + dict(id=['share-module', 'resource-box', + 'resource-box-header']) + ] + + extra_css = ''' + h1{font-family :Arial,Helvetica,sans-serif; font-size:large;} + h2{font-family :Arial,Helvetica,sans-serif; font-size:medium; color:#666666;} + h3{font-family :Arial,Helvetica,sans-serif; font-size:medium; color:#000000;} + h4{font-family :Arial,Helvetica,sans-serif; font-size: x-small;} + p{font-family :Arial,Helvetica,sans-serif; font-size:x-small;} + #story-head h1{font-family :Arial,Helvetica,sans-serif; font-size: xx-large;} + #story-head h2{font-family :Arial,Helvetica,sans-serif; font-size: small; color:#000000;} + #story-head h3{font-family :Arial,Helvetica,sans-serif; font-size: xx-small;} + #story-head h4{font-family :Arial,Helvetica,sans-serif; font-size: xx-small;} + #story{font-family :Arial,Helvetica,sans-serif; font-size:xx-small;} + #Text-TextSubhed BoldCond PoynterAgateZero h3{color:#444444;font-family :Arial,Helvetica,sans-serif; font-size:small;} + .p260x p{font-family :Arial,Helvetica,serif; font-size:x-small;font-style:italic;} + .p260x h6{color:#777777;font-family :Arial,Helvetica,sans-serif; font-size:xx-small;} + ''' + def parse_index(self): soup = self.index_to_soup('http://www.chron.com/news/') @@ -64,3 +88,6 @@ class HoustonChronicle(BasicNewsRecipe): feeds.append((current_section, current_articles)) return feeds + + + diff --git a/resources/recipes/san_fran_chronicle.recipe b/resources/recipes/san_fran_chronicle.recipe index 5649da9bf8..cfdf0b07f0 100644 --- a/resources/recipes/san_fran_chronicle.recipe +++ b/resources/recipes/san_fran_chronicle.recipe @@ -7,10 +7,11 @@ sfgate.com ''' from calibre.web.feeds.news import BasicNewsRecipe +import re class SanFranciscoChronicle(BasicNewsRecipe): title = u'San Francisco Chronicle' - __author__ = u'Darko Miletic' + __author__ = u'Darko Miletic and Sujata Raman' description = u'San Francisco news' language = 'en' @@ -19,13 +20,56 @@ class SanFranciscoChronicle(BasicNewsRecipe): no_stylesheets = True use_embedded_content = False - remove_tags_before = {'class':'articleheadings'} - remove_tags_after = dict(name='div', attrs={'id':'articlecontent' }) - remove_tags = [ - dict(name='div', attrs={'class':'tools tools_top'}) - ,dict(name='div', attrs={'id':'articlebox' }) - ] + + + remove_tags_before = {'id':'printheader'} + + remove_tags = [ + dict(name='div',attrs={'id':'printheader'}) + ,dict(name='a', attrs={'href':re.compile('http://ads\.pheedo\.com.*')}) + ,dict(name='div',attrs={'id':'footer'}) + ] + + extra_css = ''' + h1{font-family :Arial,Helvetica,sans-serif; font-size:large;} + h2{font-family :Arial,Helvetica,sans-serif; font-size:medium; color:#666666;} + h3{font-family :Arial,Helvetica,sans-serif; font-size:medium; color:#000000;} + h4{font-family :Arial,Helvetica,sans-serif; font-size: x-small;} + p{font-family :Arial,Helvetica,sans-serif; font-size:x-small;} + .byline{font-family :Arial,Helvetica,sans-serif; font-size: xx-small;} + .date{font-family :Arial,Helvetica,sans-serif; font-size: xx-small;} + .dtlcomment{font-style:italic;} + .georgia h3{font-family :Arial,Helvetica,sans-serif; font-size:x-small; color:#000000;} + ''' feeds = [ (u'Top News Stories', u'http://www.sfgate.com/rss/feeds/news.xml') ] + + def print_version(self,url): + url= url +"&type=printable" + return url + + def get_article_url(self, article): + print str(article['title_detail']['value']) + url = article.get('guid',None) + url = "http://www.sfgate.com/cgi-bin/article.cgi?f="+url + if "Presented By:" in str(article['title_detail']['value']): + url = '' + return url + + + + + + + + + + + + + + + + diff --git a/src/calibre/ebooks/rtf/preprocess.py b/src/calibre/ebooks/rtf/preprocess.py index 07e6d41fac..a3076651fd 100644 --- a/src/calibre/ebooks/rtf/preprocess.py +++ b/src/calibre/ebooks/rtf/preprocess.py @@ -131,9 +131,9 @@ class RtfTokenParser(): if isString(self.tokens[i].name, "\\'"): i = i + 1 if not isinstance(self.tokens[i], tokenData): - raise BaseException('Error: token8bitChar without data.') + raise Exception('Error: token8bitChar without data.') if len(self.tokens[i].data) < 2: - raise BaseException('Error: token8bitChar without data.') + raise Exception('Error: token8bitChar without data.') newTokens.append(token8bitChar(self.tokens[i].data[0:2])) if len(self.tokens[i].data) > 2: newTokens.append(tokenData(self.tokens[i].data[2:])) @@ -195,7 +195,7 @@ class RtfTokenParser(): i = i + 1 j = j + 1 continue - raise BaseException('Error: incorect utf replacement.') + raise Exception('Error: incorect utf replacement.') #calibre rtf2xml does not support utfreplace replace = [] @@ -248,7 +248,7 @@ class RtfTokenizer(): if isChar(self.rtfData[i], '\\'): if i + 1 >= len(self.rtfData): - raise BaseException('Error: Control character found at the end of the document.') + raise Exception('Error: Control character found at the end of the document.') if lastDataStart > -1: self.tokens.append(tokenData(self.rtfData[lastDataStart : i])) @@ -269,7 +269,7 @@ class RtfTokenizer(): i = i + 1 if not consumed: - raise BaseException('Error (at:%d): Control Word without end.'%(tokenStart)) + raise Exception('Error (at:%d): Control Word without end.'%(tokenStart)) #we have numeric argument before delimiter if isChar(self.rtfData[i], '-') or isDigit(self.rtfData[i]): @@ -283,10 +283,10 @@ class RtfTokenizer(): l = l + 1 i = i + 1 if l > 10 : - raise BaseException('Error (at:%d): Too many digits in control word numeric argument.'%[tokenStart]) + raise Exception('Error (at:%d): Too many digits in control word numeric argument.'%[tokenStart]) if not consumed: - raise BaseException('Error (at:%d): Control Word without numeric argument end.'%[tokenStart]) + raise Exception('Error (at:%d): Control Word without numeric argument end.'%[tokenStart]) separator = '' if isChar(self.rtfData[i], ' '):