mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #824490 (New recipe for The Independent)
This commit is contained in:
parent
52256a641b
commit
0a96cf092d
BIN
recipes/icons/independent.png
Normal file
BIN
recipes/icons/independent.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 343 B |
@ -1,70 +1,86 @@
|
|||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
www.independent.co.uk
|
||||||
|
'''
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
|
||||||
|
|
||||||
class TheIndependent(BasicNewsRecipe):
|
class TheIndependent(BasicNewsRecipe):
|
||||||
title = u'The Independent'
|
title = 'The Independent'
|
||||||
language = 'en_GB'
|
__author__ = 'Darko Miletic'
|
||||||
__author__ = 'Krittika Goyal'
|
description = 'Independent News - Breaking news, comment and features from The Independent newspaper'
|
||||||
oldest_article = 1 #days
|
publisher = 'The Independent'
|
||||||
max_articles_per_feed = 30
|
category = 'news, politics, UK'
|
||||||
encoding = 'latin1'
|
oldest_article = 2
|
||||||
|
max_articles_per_feed = 200
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
#remove_tags_before = dict(name='h1', attrs={'class':'heading'})
|
encoding = 'cp1252'
|
||||||
#remove_tags_after = dict(name='td', attrs={'class':'newptool1'})
|
use_embedded_content = False
|
||||||
remove_tags = [
|
language = 'en_GB'
|
||||||
dict(name='iframe'),
|
remove_empty_feeds = True
|
||||||
dict(name='div', attrs={'class':'related-articles'}),
|
publication_type = 'newspaper'
|
||||||
dict(name='div', attrs={'id':['qrformdiv', 'inSection', 'alpha-inner']}),
|
masthead_url = 'http://www.independent.co.uk/independent.co.uk/images/logo-london.png'
|
||||||
dict(name='ul', attrs={'class':'article-tools'}),
|
extra_css = """
|
||||||
dict(name='ul', attrs={'class':'articleTools'}),
|
h1{font-family: Georgia,serif }
|
||||||
|
body{font-family: Verdana,Arial,Helvetica,sans-serif}
|
||||||
|
img{margin-bottom: 0.4em; display:block}
|
||||||
|
.info,.caption,.credits{font-size: x-small}
|
||||||
|
"""
|
||||||
|
|
||||||
|
conversion_options = {
|
||||||
|
'comment' : description
|
||||||
|
, 'tags' : category
|
||||||
|
, 'publisher' : publisher
|
||||||
|
, 'language' : language
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_tags =[
|
||||||
|
dict(name=['meta','link','object','embed','iframe','base','style'])
|
||||||
|
,dict(attrs={'class':['related-articles','share','googleCols','article-tools','paging','googleArt']})
|
||||||
|
,dict(attrs={'id':['newsVideoPlayer','yahoobook','google-intext']})
|
||||||
]
|
]
|
||||||
|
keep_only_tags =[dict(attrs={'id':'article'})]
|
||||||
|
remove_attributes=['lang','onclick','width','xmlns:fb']
|
||||||
|
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
('UK',
|
(u'UK' , u'http://www.independent.co.uk/news/uk/rss' )
|
||||||
'http://www.independent.co.uk/news/uk/rss'),
|
,(u'World' , u'http://www.independent.co.uk/news/world/rss' )
|
||||||
('World',
|
,(u'Business' , u'http://www.independent.co.uk/news/business/rss' )
|
||||||
'http://www.independent.co.uk/news/world/rss'),
|
,(u'People' , u'http://www.independent.co.uk/news/people/rss' )
|
||||||
('Business',
|
,(u'Science' , u'http://www.independent.co.uk/news/science/rss' )
|
||||||
'http://www.independent.co.uk/news/business/rss'),
|
,(u'Media' , u'http://www.independent.co.uk/news/media/rss' )
|
||||||
('People',
|
,(u'Education' , u'http://www.independent.co.uk/news/education/rss' )
|
||||||
'http://www.independent.co.uk/news/people/rss'),
|
,(u'Leading Articles' , u'http://www.independent.co.uk/opinion/leading-articles/rss')
|
||||||
('Science',
|
,(u'Comentators' , u'http://www.independent.co.uk/opinion/commentators/rss' )
|
||||||
'http://www.independent.co.uk/news/science/rss'),
|
,(u'Columnists' , u'http://www.independent.co.uk/opinion/columnists/rss' )
|
||||||
('Media',
|
,(u'Letters' , u'http://www.independent.co.uk/opinion/letters/rss' )
|
||||||
'http://www.independent.co.uk/news/media/rss'),
|
,(u'Big Question' , u'http://www.independent.co.uk/extras/big-question/rss' )
|
||||||
('Education',
|
,(u'Sport' , u'http://www.independent.co.uk/sport/rss' )
|
||||||
'http://www.independent.co.uk/news/education/rss'),
|
,(u'Life&Style' , u'http://www.independent.co.uk/life-style/rss' )
|
||||||
('Obituaries',
|
,(u'Arts&Entertainment' , u'http://www.independent.co.uk/arts-entertainment/rss' )
|
||||||
'http://www.independent.co.uk/news/obituaries/rss'),
|
,(u'Travel' , u'http://www.independent.co.uk/travel/rss' )
|
||||||
|
,(u'Money' , u'http://www.independent.co.uk/money/rss' )
|
||||||
('Opinion',
|
|
||||||
'http://www.independent.co.uk/opinion/rss'),
|
|
||||||
|
|
||||||
('Environment',
|
|
||||||
'http://www.independent.co.uk/environment/rss'),
|
|
||||||
|
|
||||||
('Sport',
|
|
||||||
'http://www.independent.co.uk/sport/rss'),
|
|
||||||
|
|
||||||
('Life and Style',
|
|
||||||
'http://www.independent.co.uk/life-style/rss'),
|
|
||||||
|
|
||||||
('Arts and Entertainment',
|
|
||||||
'http://www.independent.co.uk/arts-entertainment/rss'),
|
|
||||||
|
|
||||||
('Travel',
|
|
||||||
'http://www.independent.co.uk/travel/rss'),
|
|
||||||
|
|
||||||
('Money',
|
|
||||||
'http://www.independent.co.uk/money/rss'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_article_url(self, article):
|
||||||
|
return article.get('guid', None)
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
story = soup.find(name='div', attrs={'id':'mainColumn'})
|
for item in soup.body.findAll(style=True):
|
||||||
#td = heading.findParent(name='td')
|
del item['style']
|
||||||
#td.extract()
|
for item in soup.body.findAll(['author','preform']):
|
||||||
soup = BeautifulSoup('<html><head><title>t</title></head><body></body></html>')
|
item.name='span'
|
||||||
body = soup.find(name='body')
|
for item in soup.body.findAll('img'):
|
||||||
body.insert(0, story)
|
if not item.has_key('alt'):
|
||||||
return soup
|
item['alt'] = 'image'
|
||||||
|
for item in soup.body.findAll('div', attrs={'class':['clear-o','body','photoCaption']}):
|
||||||
|
item.name = 'p'
|
||||||
|
for item in soup.body.findAll('div'):
|
||||||
|
if not item.attrs and not item.contents:
|
||||||
|
item.extract()
|
||||||
|
soup2 = BeautifulSoup('<html><head><title>t</title></head><body></body></html>')
|
||||||
|
soup2.body.replaceWith(soup.body)
|
||||||
|
return soup2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user