Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Mar 3, 2024
2 parents c38bacc + 1f41eeb commit 3828835
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions recipes/mit_technology_review.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ technologyreview.com
'''
from calibre.web.feeds.news import BasicNewsRecipe, prefixed_classes
from collections import OrderedDict
import re
import json

def absurl(x):
if x.startswith('//'):
Expand Down Expand Up @@ -66,8 +66,9 @@ class MitTechnologyReview(BasicNewsRecipe):
def get_cover_url(self):
soup = self.index_to_soup('https://www.technologyreview.com/')
if script := soup.find('script', id='preload'):
link = re.search('(https\S+?front_cover\S+?(jpg|png))', self.tag_to_string(script))
return link.group(1) + '?fit=572,786'
JSON = script.contents[0].split('magazineCover\":')[1].strip()
data = json.JSONDecoder().raw_decode(JSON)[0]
return data['config']['src']

def parse_index(self):
soup = self.index_to_soup(self.INDEX)
Expand Down

0 comments on commit 3828835

Please sign in to comment.