mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Update science_journal.recipe
This commit is contained in:
parent
662d5ba809
commit
c9a05cefd6
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
from calibre.web.feeds.news import BasicNewsRecipe, classes, prefixed_classes
|
||||||
|
|
||||||
|
|
||||||
def absurl(url):
|
def absurl(url):
|
||||||
@ -25,7 +25,7 @@ class science(BasicNewsRecipe):
|
|||||||
browser_type = 'webengine'
|
browser_type = 'webengine'
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
.news-article__figure__caption, .figc {font-size:small;}
|
.news-article__figure__caption, .calibre-nuked-tag-figcaption, .card-related {font-size:small;}
|
||||||
.core-self-citation, .meta-panel__left-content, .news-article__hero__top-meta {font-size:small;}
|
.core-self-citation, .meta-panel__left-content, .news-article__hero__top-meta {font-size:small;}
|
||||||
.contributors, .news-article__hero__bottom-meta, #bibliography, #elettersSection {font-size:small;}
|
.contributors, .news-article__hero__bottom-meta, #bibliography, #elettersSection {font-size:small;}
|
||||||
img {display:block; margin:0 auto;}
|
img {display:block; margin:0 auto;}
|
||||||
@ -59,9 +59,6 @@ class science(BasicNewsRecipe):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for p in soup.findAll(attrs={'role':'paragraph'}):
|
|
||||||
p.name = 'p'
|
|
||||||
p.attrs = {}
|
|
||||||
for img in soup.findAll('img', attrs={'src':True}):
|
for img in soup.findAll('img', attrs={'src':True}):
|
||||||
if img['src'].endswith('.jpg'):
|
if img['src'].endswith('.jpg'):
|
||||||
res = '/cdn-cgi/image/width=600'
|
res = '/cdn-cgi/image/width=600'
|
||||||
@ -69,8 +66,12 @@ class science(BasicNewsRecipe):
|
|||||||
if w and isinstance(w, str):
|
if w and isinstance(w, str):
|
||||||
res = '/cdn-cgi/image/width=' + w
|
res = '/cdn-cgi/image/width=' + w
|
||||||
img['src'] = absurl(res + img['src'])
|
img['src'] = absurl(res + img['src'])
|
||||||
for figc in soup.findAll('figcaption'):
|
return soup
|
||||||
figc['class'] = 'figc'
|
|
||||||
|
def postprocess_html(self, soup, first_fetch):
|
||||||
|
bd = soup.find('body')
|
||||||
|
if bd:
|
||||||
|
p.attrs = {}
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
@ -92,7 +93,7 @@ class science(BasicNewsRecipe):
|
|||||||
|
|
||||||
feeds = []
|
feeds = []
|
||||||
|
|
||||||
for sec in soup.findAll('section', **classes('toc__section')):
|
for sec in soup.findAll('section', **prefixed_classes('toc__section')):
|
||||||
name = sec.find(**classes('sidebar-article-title--decorated'))
|
name = sec.find(**classes('sidebar-article-title--decorated'))
|
||||||
section = self.tag_to_string(name).strip()
|
section = self.tag_to_string(name).strip()
|
||||||
self.log(section)
|
self.log(section)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user