mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Daily Express
This commit is contained in:
parent
fce5bebc16
commit
6fc515a66a
@ -1,72 +1,70 @@
|
|||||||
|
# vim:fileencoding=UTF-8
|
||||||
|
from __future__ import unicode_literals
|
||||||
import re
|
import re
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
class AdvancedUserRecipe1376229553(BasicNewsRecipe):
|
class AdvancedUserRecipe1376229553(BasicNewsRecipe):
|
||||||
title = u'Daily Express'
|
title = 'Daily Express'
|
||||||
__author__ = 'Dave Asbury'
|
__author__ = 'Dave Asbury'
|
||||||
# 9-9-13 added article author and now use (re.compile(r'>[\w].+? News<'
|
# 9-9-13 added article author and now use (re.compile(r'>[\w].+? News<'
|
||||||
# 16-11-13 cover adjustment
|
# 16-11-13 cover adjustment
|
||||||
|
# 19.1.14 changes due to website changes breaking recipe
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
#remove_javascript = True
|
remove_javascript = True
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
oldest_article = 1
|
oldest_article = 1
|
||||||
max_articles_per_feed = 10
|
max_articles_per_feed = 2
|
||||||
#auto_cleanup = True
|
#auto_cleanup = True
|
||||||
compress_news_images = True
|
compress_news_images = True
|
||||||
compress_news_images_max_size = 30
|
compress_news_images_max_size = 30
|
||||||
ignore_duplicate_articles = {'title', 'url'}
|
ignore_duplicate_articles = {'title', 'url'}
|
||||||
masthead_url = 'http://cdn.images.dailyexpress.co.uk/img/page/express_logo.png'
|
masthead_url = 'http://cdn.images.dailyexpress.co.uk/img/page/express_logo.png'
|
||||||
|
#conversion_options = { 'linearize_tables' : True }
|
||||||
preprocess_regexps = [
|
|
||||||
|
|
||||||
(re.compile(r'widget', re.IGNORECASE | re.DOTALL), lambda match: ''),
|
|
||||||
(re.compile(r'Related articles', re.IGNORECASE | re.DOTALL), lambda match: ''),
|
|
||||||
(re.compile(r'Add Your Comment<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
(re.compile(r'>More [\w].+?<', re.IGNORECASE), lambda match: '><'),
|
|
||||||
(re.compile(r'>[\w].+? News<', re.IGNORECASE), lambda match: '><'),
|
|
||||||
#(re.compile(r'Health News<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'Car News<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'TV & Radio News<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'Food & Recipe News<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'More City & Business<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'Travel News<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'Garden News<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'Fashion & Beauty News<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'More Personal Finance<', re.IGNORECASE | re.DOTALL), lambda match: '<'),
|
|
||||||
#(re.compile(r'<h3>More UK</h3>', re.IGNORECASE | re.DOTALL), lambda match: ''),
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(attrs={'class' : 'quote'}),
|
dict(attrs={'class' : 'quote'}),
|
||||||
#dict(attrs={'class' : 'author'}),
|
dict(attrs={'class' : 'mainFooter cf'}),
|
||||||
dict(name='footer'),
|
dict(name='footer'),
|
||||||
dict(attrs={'id' : 'header_addons'}),
|
dict(attrs={'id' : 'header_addons'}),
|
||||||
dict(attrs={'class' : 'hoverException'}),
|
dict(attrs={'class' : 'hoverException'}),
|
||||||
dict(name='_li'),dict(name='li'),
|
dict(name='_li'),dict(name='li'),
|
||||||
dict(attrs={'class' : 'box related-articles clear'}),
|
dict(attrs={'class' : 'box related-articles clear'}),
|
||||||
dict(attrs={'class' : 'news-list'}),
|
dict(attrs={'class' : 'news-list'}),
|
||||||
dict(attrs={'class' : 'sponsored-section'}),
|
dict(attrs={'class' : 'sponsored-section'}),
|
||||||
dict(attrs={'class' : 'pull-quote on-right'}),
|
dict(attrs={'class' : 'pull-quote on-right'}),
|
||||||
dict(attrs={'class' : 'pull-quote on-left'}),
|
dict(attrs={'class' : 'pull-quote on-left'}),
|
||||||
|
|
||||||
]
|
]
|
||||||
keep_only_tags = [
|
remove_tags_after = [dict(attrs={'class' : 'clearfix hR new-style'})]
|
||||||
dict(name='h1'),
|
extra_css = '''
|
||||||
dict(attrs={'class' : 'publish-info'}),
|
h1{font-weight:bold;font-size:175%;}
|
||||||
dict(name='h3', limit=2),
|
h2{font-weight:normal;font-size:75%;}
|
||||||
dict(attrs={'class' : 'clearfix hR new-style'}),
|
#p{font-size:14px;}
|
||||||
]
|
#body{font-size:14px;}
|
||||||
|
.photo-caption {display: block;margin-left: auto;margin-right: auto;width:100%;font-size:40%;}
|
||||||
|
.publish-info {font-size:50%;}
|
||||||
|
.photo img {display: block;margin-left: auto;margin-right: auto;width:100%;}
|
||||||
|
'''
|
||||||
|
|
||||||
feeds = [(u'UK News', u'http://www.express.co.uk/posts/rss/1/uk'),
|
feeds = [
|
||||||
(u'World News',u'http://www.express.co.uk/posts/rss/78/world'),
|
('UK News', 'http://www.express.co.uk/posts/rss/1/uk'),
|
||||||
(u'Finance',u'http://www.express.co.uk/posts/rss/21/finance'),
|
('World News','http://www.express.co.uk/posts/rss/78/world'),
|
||||||
(u'Sport',u'http://www.express.co.uk/posts/rss/65/sport'),
|
('Finance','http://www.express.co.uk/posts/rss/21/finance'),
|
||||||
(u'Entertainment',u'http://www.express.co.uk/posts/rss/18/entertainment'),
|
('Sport','http://www.express.co.uk/posts/rss/65/sport'),
|
||||||
(u'Lifestyle',u'http://www.express.co.uk/posts/rss/8/life&style'),
|
('Entertainment','http://www.express.co.uk/posts/rss/18/entertainment'),
|
||||||
(u'Fun',u'http://www.express.co.uk/posts/rss/110/fun'),
|
('Lifestyle','http://www.express.co.uk/posts/rss/8/life&style'),
|
||||||
]
|
('Fun','http://www.express.co.uk/posts/rss/110/fun'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def preprocess_raw_html(self, raw_html, url):
|
||||||
|
for pat, f in [
|
||||||
|
(re.compile(r'<head.+?</head>', re.DOTALL), lambda m: '<head></head>'),
|
||||||
|
(re.compile(r'<!—.*?—>',re.DOTALL), lambda m: ''),
|
||||||
|
(re.compile(r'<!--.*?-->',re.DOTALL), lambda m: ''),
|
||||||
|
]:
|
||||||
|
raw_html = pat.sub(f, raw_html)
|
||||||
|
return raw_html
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
soup = self.index_to_soup('http://www.express.co.uk/ourpaper/')
|
soup = self.index_to_soup('http://www.express.co.uk/ourpaper/')
|
||||||
@ -87,12 +85,4 @@ class AdvancedUserRecipe1376229553(BasicNewsRecipe):
|
|||||||
|
|
||||||
return cover_url
|
return cover_url
|
||||||
|
|
||||||
extra_css = '''
|
|
||||||
h1{font-weight:bold;font-size:175%;}
|
|
||||||
h2{font-weight:normal;font-size:75%;}
|
|
||||||
#p{font-size:14px;}
|
|
||||||
#body{font-size:14px;}
|
|
||||||
.photo-caption {display: block;margin-left: auto;margin-right: auto;width:100%;font-size:40%;}
|
|
||||||
.publish-info {font-size:50%;}
|
|
||||||
.photo img {display: block;margin-left: auto;margin-right: auto;width:100%;}
|
|
||||||
'''
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user