mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update The Sun
This commit is contained in:
parent
deb13bf346
commit
151378b514
@ -1,49 +1,57 @@
|
|||||||
import re
|
import re
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||||
from calibre.ebooks.BeautifulSoup import Tag
|
|
||||||
|
|
||||||
class AdvancedUserRecipe1268409464(BasicNewsRecipe):
|
class AdvancedUserRecipe1325006965(BasicNewsRecipe):
|
||||||
title = u'The Sun'
|
|
||||||
__author__ = 'Chaz Ralph'
|
title = u'The Sun UK'
|
||||||
description = 'News from The Sun'
|
cover_url = 'http://www.thesun.co.uk/img/global/new-masthead-logo.png'
|
||||||
|
|
||||||
|
description = 'A Recipe for The Sun tabloid UK - uses feed43'
|
||||||
|
__author__ = 'Dave Asbury'
|
||||||
|
# last updated 20/2/12
|
||||||
|
language = 'en_GB'
|
||||||
oldest_article = 1
|
oldest_article = 1
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 15
|
||||||
language = 'en'
|
remove_empty_feeds = True
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
extra_css = '.headline {font-size: x-large;} \n .fact { padding-top: 10pt }'
|
|
||||||
encoding= 'iso-8859-1'
|
masthead_url = 'http://www.thesun.co.uk/sol/img/global/Sun-logo.gif'
|
||||||
remove_javascript = True
|
encoding = 'cp1251'
|
||||||
|
|
||||||
|
encoding = 'cp1252'
|
||||||
|
remove_empty_feeds = True
|
||||||
|
remove_javascript = True
|
||||||
|
no_stylesheets = True
|
||||||
|
|
||||||
|
extra_css = '''
|
||||||
|
body{ text-align: justify; font-family:Arial,Helvetica,sans-serif; font-size:11px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:normal;}
|
||||||
|
'''
|
||||||
|
|
||||||
|
preprocess_regexps = [
|
||||||
|
(re.compile(r'<div class="foot-copyright".*?</div>', re.IGNORECASE | re.DOTALL), lambda match: '')]
|
||||||
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
dict(id='column-print')
|
dict(name='h1'),dict(name='h2',attrs={'class' : 'medium centered'}),
|
||||||
|
dict(name='div',attrs={'class' : 'text-center'}),
|
||||||
|
dict(name='div',attrs={'id' : 'bodyText'})
|
||||||
|
# dict(name='p')
|
||||||
|
]
|
||||||
|
|
||||||
|
remove_tags=[
|
||||||
|
#dict(name='head'),
|
||||||
|
dict(attrs={'class' : ['mystery-meat-link','ltbx-container','ltbx-var ltbx-hbxpn','ltbx-var ltbx-nav-loop','ltbx-var ltbx-url']}),
|
||||||
|
dict(name='div',attrs={'class' : 'cf'}),
|
||||||
|
dict(attrs={'title' : 'download flash'}),
|
||||||
|
dict(attrs={'style' : 'padding: 5px'})
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
feeds = [
|
||||||
|
(u'News','http://feed43.com/2517447382644748.xml'),
|
||||||
|
(u'Sport', u'http://feed43.com/4283846255668687.xml'),
|
||||||
|
(u'Bizarre', u'http://feed43.com/0233840304242011.xml'),
|
||||||
|
(u'Film',u'http://feed43.com/1307545221226200.xml'),
|
||||||
|
(u'Music',u'http://feed43.com/1701513435064132.xml'),
|
||||||
|
(u'Sun Woman',u'http://feed43.com/0022626854226453.xml'),
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_tags = [
|
|
||||||
dict(name='div', attrs={'class':[
|
|
||||||
'clear text-center small padding-left-right-5 text-999 padding-top-5 padding-bottom-10 grey-solid-line',
|
|
||||||
'clear width-625 bg-fff padding-top-10'
|
|
||||||
]}),
|
|
||||||
dict(name='video'),
|
|
||||||
]
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
|
||||||
h1 = soup.find('h1')
|
|
||||||
if h1 is not None:
|
|
||||||
text = self.tag_to_string(h1)
|
|
||||||
nh = Tag(soup, 'h1')
|
|
||||||
nh.insert(0, text)
|
|
||||||
h1.replaceWith(nh)
|
|
||||||
|
|
||||||
return soup
|
|
||||||
|
|
||||||
|
|
||||||
feeds = [(u'News', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article312900.ece')
|
|
||||||
,(u'Sport', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247732.ece')
|
|
||||||
,(u'Football', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247739.ece')
|
|
||||||
,(u'Gizmo', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247829.ece')
|
|
||||||
,(u'Bizarre', u'http://www.thesun.co.uk/sol/homepage/feeds/rss/article247767.ece')]
|
|
||||||
|
|
||||||
def print_version(self, url):
|
|
||||||
return re.sub(r'\?OTC-RSS&ATTR=[-a-zA-Z]+', '?print=yes', url)
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user