mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Improve recipe for Journal of Nephrology
This commit is contained in:
parent
1b4ec12d6d
commit
6027e401d7
@ -15,13 +15,13 @@ class JASN(BasicNewsRecipe):
|
|||||||
remove_tags_before = dict(name='h2')
|
remove_tags_before = dict(name='h2')
|
||||||
#remove_tags_after = dict(name='th', attrs={'align':'left'})
|
#remove_tags_after = dict(name='th', attrs={'align':'left'})
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name='iframe'),
|
dict(name='iframe'),
|
||||||
#dict(name='div', attrs={'class':'related-articles'}),
|
#dict(name='div', attrs={'class':'related-articles'}),
|
||||||
dict(name='td', attrs={'id':['jasnFooter']}),
|
dict(name='td', attrs={'id':['jasnFooter']}),
|
||||||
dict(name='table', attrs={'id':"jasnNavBar"}),
|
dict(name='table', attrs={'id':"jasnNavBar"}),
|
||||||
dict(name='table', attrs={'class':'content_box_outer_table'}),
|
dict(name='table', attrs={'class':'content_box_outer_table'}),
|
||||||
dict(name='th', attrs={'align':'left'})
|
dict(name='th', attrs={'align':'left'})
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -45,10 +45,52 @@ class JASN(BasicNewsRecipe):
|
|||||||
raise ValueError('Failed to log in, is your account expired?')
|
raise ValueError('Failed to log in, is your account expired?')
|
||||||
return br
|
return br
|
||||||
|
|
||||||
feeds = [
|
#feeds = [
|
||||||
('JASN',
|
#('JASN',
|
||||||
'http://jasn.asnjournals.org/rss/current.xml'),
|
#'http://jasn.asnjournals.org/rss/current.xml'),
|
||||||
]
|
#]
|
||||||
|
|
||||||
|
|
||||||
|
#TO GET ARTICLE TOC
|
||||||
|
def jasn_get_index(self):
|
||||||
|
return self.index_to_soup('http://jasn.asnjournals.org/current.shtml')
|
||||||
|
|
||||||
|
# To parse artice toc
|
||||||
|
def parse_index(self):
|
||||||
|
parse_soup = self.jasn_get_index()
|
||||||
|
|
||||||
|
div = parse_soup.find(id='tocBody')
|
||||||
|
|
||||||
|
current_section = None
|
||||||
|
current_articles = []
|
||||||
|
feeds = []
|
||||||
|
for x in div.findAll(True):
|
||||||
|
if x.name == 'h2':
|
||||||
|
# Section heading found
|
||||||
|
if current_articles and current_section:
|
||||||
|
feeds.append((current_section, current_articles))
|
||||||
|
current_section = self.tag_to_string(x)
|
||||||
|
current_articles = []
|
||||||
|
self.log('\tFound section:', current_section)
|
||||||
|
if current_section is not None and x.name == 'strong':
|
||||||
|
title = self.tag_to_string(x)
|
||||||
|
a = x.parent.parent.find('a', href=lambda x: x and '/full/' in x)
|
||||||
|
if a is None:
|
||||||
|
continue
|
||||||
|
url = a.get('href', False)
|
||||||
|
if not url or not title:
|
||||||
|
continue
|
||||||
|
if url.startswith('/'):
|
||||||
|
url = 'http://jasn.asnjournals.org'+url
|
||||||
|
self.log('\t\tFound article:', title)
|
||||||
|
self.log('\t\t\t', url)
|
||||||
|
current_articles.append({'title': title, 'url':url,
|
||||||
|
'description':'', 'date':''})
|
||||||
|
|
||||||
|
if current_articles and current_section:
|
||||||
|
feeds.append((current_section, current_articles))
|
||||||
|
|
||||||
|
return feeds
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +101,7 @@ class JASN(BasicNewsRecipe):
|
|||||||
if not url:
|
if not url:
|
||||||
continue
|
continue
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
url = 'http://jasn.asnjournals.org/'+url
|
url = 'http://jasn.asnjournals.org'+url
|
||||||
isoup = self.index_to_soup(url)
|
isoup = self.index_to_soup(url)
|
||||||
img = isoup.find('img', src=lambda x: x and
|
img = isoup.find('img', src=lambda x: x and
|
||||||
x.startswith('/content/'))
|
x.startswith('/content/'))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user