mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improved reciped for San Frna Chronicle and Houston Chronicle
This commit is contained in:
parent
d9c267d204
commit
7ca92a591c
@ -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
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class HoustonChronicle(BasicNewsRecipe):
|
class HoustonChronicle(BasicNewsRecipe):
|
||||||
|
|
||||||
title = u'The Houston Chronicle'
|
title = u'The Houston Chronicle'
|
||||||
description = 'News from Houston, Texas'
|
description = 'News from Houston, Texas'
|
||||||
__author__ = 'Kovid Goyal'
|
__author__ = 'Kovid Goyal and Sujata Raman'
|
||||||
language = 'en'
|
language = 'en'
|
||||||
timefmt = ' [%a, %d %b, %Y]'
|
timefmt = ' [%a, %d %b, %Y]'
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
|
|
||||||
keep_only_tags = [dict(id=['story-head', 'story'])]
|
keep_only_tags = [
|
||||||
remove_tags = [dict(id=['share-module', 'resource-box',
|
dict(id=['story-head', 'story'])
|
||||||
'resource-box-header'])]
|
]
|
||||||
|
|
||||||
|
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):
|
def parse_index(self):
|
||||||
soup = self.index_to_soup('http://www.chron.com/news/')
|
soup = self.index_to_soup('http://www.chron.com/news/')
|
||||||
@ -64,3 +88,6 @@ class HoustonChronicle(BasicNewsRecipe):
|
|||||||
feeds.append((current_section, current_articles))
|
feeds.append((current_section, current_articles))
|
||||||
return feeds
|
return feeds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@ sfgate.com
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
import re
|
||||||
|
|
||||||
class SanFranciscoChronicle(BasicNewsRecipe):
|
class SanFranciscoChronicle(BasicNewsRecipe):
|
||||||
title = u'San Francisco Chronicle'
|
title = u'San Francisco Chronicle'
|
||||||
__author__ = u'Darko Miletic'
|
__author__ = u'Darko Miletic and Sujata Raman'
|
||||||
description = u'San Francisco news'
|
description = u'San Francisco news'
|
||||||
language = 'en'
|
language = 'en'
|
||||||
|
|
||||||
@ -19,13 +20,56 @@ class SanFranciscoChronicle(BasicNewsRecipe):
|
|||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
|
|
||||||
remove_tags_before = {'class':'articleheadings'}
|
|
||||||
remove_tags_after = dict(name='div', attrs={'id':'articlecontent' })
|
|
||||||
remove_tags = [
|
remove_tags_before = {'id':'printheader'}
|
||||||
dict(name='div', attrs={'class':'tools tools_top'})
|
|
||||||
,dict(name='div', attrs={'id':'articlebox' })
|
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 = [
|
feeds = [
|
||||||
(u'Top News Stories', u'http://www.sfgate.com/rss/feeds/news.xml')
|
(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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,9 +131,9 @@ class RtfTokenParser():
|
|||||||
if isString(self.tokens[i].name, "\\'"):
|
if isString(self.tokens[i].name, "\\'"):
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if not isinstance(self.tokens[i], tokenData):
|
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:
|
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]))
|
newTokens.append(token8bitChar(self.tokens[i].data[0:2]))
|
||||||
if len(self.tokens[i].data) > 2:
|
if len(self.tokens[i].data) > 2:
|
||||||
newTokens.append(tokenData(self.tokens[i].data[2:]))
|
newTokens.append(tokenData(self.tokens[i].data[2:]))
|
||||||
@ -195,7 +195,7 @@ class RtfTokenParser():
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
j = j + 1
|
j = j + 1
|
||||||
continue
|
continue
|
||||||
raise BaseException('Error: incorect utf replacement.')
|
raise Exception('Error: incorect utf replacement.')
|
||||||
|
|
||||||
#calibre rtf2xml does not support utfreplace
|
#calibre rtf2xml does not support utfreplace
|
||||||
replace = []
|
replace = []
|
||||||
@ -248,7 +248,7 @@ class RtfTokenizer():
|
|||||||
|
|
||||||
if isChar(self.rtfData[i], '\\'):
|
if isChar(self.rtfData[i], '\\'):
|
||||||
if i + 1 >= len(self.rtfData):
|
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:
|
if lastDataStart > -1:
|
||||||
self.tokens.append(tokenData(self.rtfData[lastDataStart : i]))
|
self.tokens.append(tokenData(self.rtfData[lastDataStart : i]))
|
||||||
@ -269,7 +269,7 @@ class RtfTokenizer():
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
if not consumed:
|
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
|
#we have numeric argument before delimiter
|
||||||
if isChar(self.rtfData[i], '-') or isDigit(self.rtfData[i]):
|
if isChar(self.rtfData[i], '-') or isDigit(self.rtfData[i]):
|
||||||
@ -283,10 +283,10 @@ class RtfTokenizer():
|
|||||||
l = l + 1
|
l = l + 1
|
||||||
i = i + 1
|
i = i + 1
|
||||||
if l > 10 :
|
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:
|
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 = ''
|
separator = ''
|
||||||
if isChar(self.rtfData[i], ' '):
|
if isChar(self.rtfData[i], ' '):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user