mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update natgeomag.recipe
This commit is contained in:
parent
e9fa788d8f
commit
6a88069f01
@ -23,8 +23,10 @@ def classes(classes):
|
|||||||
def extract_json(raw):
|
def extract_json(raw):
|
||||||
s = raw.find("window['__natgeo__']")
|
s = raw.find("window['__natgeo__']")
|
||||||
script = raw[s:raw.find('</script>', s)]
|
script = raw[s:raw.find('</script>', s)]
|
||||||
return json.loads(
|
data = json.loads(script[script.find('{'):].rstrip(';'))['page']['content']
|
||||||
script[script.find('{'):].rstrip(';'))['page']['content']['article']
|
if 'article' in data:
|
||||||
|
return data['article']
|
||||||
|
return data['prismarticle']
|
||||||
|
|
||||||
|
|
||||||
def parse_contributors(grp):
|
def parse_contributors(grp):
|
||||||
@ -36,6 +38,7 @@ def parse_contributors(grp):
|
|||||||
|
|
||||||
|
|
||||||
def parse_lead_image(media):
|
def parse_lead_image(media):
|
||||||
|
if 'image' in media:
|
||||||
if 'dsc' in media['image']:
|
if 'dsc' in media['image']:
|
||||||
yield '<p><div><img src="{}" alt="{}"></div>'.format(
|
yield '<p><div><img src="{}" alt="{}"></div>'.format(
|
||||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user