mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update mit_technology_review.recipe
cover
This commit is contained in:
parent
c38bacc0ba
commit
1f41eeb359
@ -10,7 +10,7 @@ technologyreview.com
|
|||||||
'''
|
'''
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe, prefixed_classes
|
from calibre.web.feeds.news import BasicNewsRecipe, prefixed_classes
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import re
|
import json
|
||||||
|
|
||||||
def absurl(x):
|
def absurl(x):
|
||||||
if x.startswith('//'):
|
if x.startswith('//'):
|
||||||
@ -66,8 +66,9 @@ class MitTechnologyReview(BasicNewsRecipe):
|
|||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
soup = self.index_to_soup('https://www.technologyreview.com/')
|
soup = self.index_to_soup('https://www.technologyreview.com/')
|
||||||
if script := soup.find('script', id='preload'):
|
if script := soup.find('script', id='preload'):
|
||||||
link = re.search('(https\S+?front_cover\S+?(jpg|png))', self.tag_to_string(script))
|
JSON = script.contents[0].split('magazineCover\":')[1].strip()
|
||||||
return link.group(1) + '?fit=572,786'
|
data = json.JSONDecoder().raw_decode(JSON)[0]
|
||||||
|
return data['config']['src']
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
soup = self.index_to_soup(self.INDEX)
|
soup = self.index_to_soup(self.INDEX)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user