mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Fix #2084 (Updated New Scientist recipe)
This commit is contained in:
parent
6e5547011a
commit
08b3ee1a79
@ -1,48 +1,69 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2008-2009, AprilHare, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
newscientist.com
|
newscientist.com
|
||||||
'''
|
'''
|
||||||
#!/usr/bin/env python
|
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
__license__ = 'GPL v3'
|
|
||||||
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>, AprilHare'
|
class NewScientist(BasicNewsRecipe):
|
||||||
'''
|
title = 'New Scientist - Online News'
|
||||||
newscientist.com
|
__author__ = 'Darko Miletic'
|
||||||
'''
|
description = 'Science news and science articles from New Scientist.'
|
||||||
|
language = _('English')
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
publisher = 'New Scientist'
|
||||||
|
category = 'science news, science articles, science jobs, drugs, cancer, depression, computer software, sex'
|
||||||
class NewScientist(BasicNewsRecipe):
|
delay = 3
|
||||||
title = u'New Scientist - Online News'
|
oldest_article = 7
|
||||||
__author__ = 'Darko Miletic'
|
max_articles_per_feed = 100
|
||||||
description = 'News from Science'
|
no_stylesheets = True
|
||||||
language = _('English')
|
use_embedded_content = False
|
||||||
oldest_article = 7
|
remove_javascript = True
|
||||||
max_articles_per_feed = 100
|
encoding = 'utf-8'
|
||||||
no_stylesheets = True
|
|
||||||
use_embedded_content = False
|
html2lrf_options = [
|
||||||
|
'--comment', description
|
||||||
keep_only_tags = [
|
, '--category', category
|
||||||
dict(name='div' , attrs={'id':'pgtop' })
|
, '--publisher', publisher
|
||||||
,dict(name='div' , attrs={'id':'maincol' })
|
]
|
||||||
]
|
|
||||||
remove_tags = [
|
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||||
dict(name='div' , attrs={'class':'hldBd' })
|
|
||||||
,dict(name='div' , attrs={'id':'compnl' })
|
keep_only_tags = [dict(name='div', attrs={'id':['pgtop','maincol']})]
|
||||||
,dict(name='div' , attrs={'id':'artIssueInfo' })
|
|
||||||
]
|
remove_tags = [
|
||||||
|
dict(name='div', attrs={'class':['hldBd','adline','pnl','infotext' ]})
|
||||||
feeds = [
|
,dict(name='div', attrs={'id' :['compnl','artIssueInfo','artTools']})
|
||||||
(u'Latest Headlines' , u'http://feeds.newscientist.com/science-news' )
|
,dict(name='p' , attrs={'class':['marker','infotext' ]})
|
||||||
,(u'Magazine' , u'http://www.newscientist.com/feed/magazine' )
|
]
|
||||||
,(u'Health' , u'http://www.newscientist.com/feed/view?id=2&type=channel' )
|
|
||||||
,(u'Life' , u'http://www.newscientist.com/feed/view?id=3&type=channel' )
|
feeds = [
|
||||||
,(u'Space' , u'http://www.newscientist.com/feed/view?id=6&type=channel' )
|
(u'Latest Headlines' , u'http://feeds.newscientist.com/science-news' )
|
||||||
,(u'Physics and Mathematics' , u'http://www.newscientist.com/feed/view?id=4&type=channel' )
|
,(u'Magazine' , u'http://www.newscientist.com/feed/magazine' )
|
||||||
,(u'Environment' , u'http://www.newscientist.com/feed/view?id=1&type=channel' )
|
,(u'Health' , u'http://www.newscientist.com/feed/view?id=2&type=channel' )
|
||||||
,(u'Science in Society' , u'http://www.newscientist.com/feed/view?id=5&type=channel' )
|
,(u'Life' , u'http://www.newscientist.com/feed/view?id=3&type=channel' )
|
||||||
,(u'Tech' , u'http://www.newscientist.com/feed/view?id=7&type=channel' )
|
,(u'Space' , u'http://www.newscientist.com/feed/view?id=6&type=channel' )
|
||||||
]
|
,(u'Physics and Mathematics' , u'http://www.newscientist.com/feed/view?id=4&type=channel' )
|
||||||
|
,(u'Environment' , u'http://www.newscientist.com/feed/view?id=1&type=channel' )
|
||||||
|
,(u'Science in Society' , u'http://www.newscientist.com/feed/view?id=5&type=channel' )
|
||||||
|
,(u'Tech' , u'http://www.newscientist.com/feed/view?id=7&type=channel' )
|
||||||
|
]
|
||||||
|
|
||||||
|
def get_article_url(self, article):
|
||||||
|
url = article.get('link', None)
|
||||||
|
raw = article.get('description', None)
|
||||||
|
rsoup = self.index_to_soup(raw)
|
||||||
|
atags = rsoup.findAll('a',href=True)
|
||||||
|
for atag in atags:
|
||||||
|
if atag['href'].startswith('http://res.feedsportal.com/viral/sendemail2.html?'):
|
||||||
|
st, sep, rest = atag['href'].partition('&link=')
|
||||||
|
real_url, sep2, drest = rest.partition('" target=')
|
||||||
|
return real_url
|
||||||
|
return url
|
||||||
|
|
||||||
|
def print_version(self, url):
|
||||||
|
rawurl, sep, params = url.partition('?')
|
||||||
|
return rawurl + '?full=true&print=true'
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user