From e6e1f54f8ca056da8e1f43615229b0de5bb9d471 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 26 Mar 2021 08:42:21 +0530 Subject: [PATCH] Economist JSON format has changed --- recipes/economist.recipe | 2 ++ recipes/economist_free.recipe | 2 ++ 2 files changed, 4 insertions(+) diff --git a/recipes/economist.recipe b/recipes/economist.recipe index a2113f1c2f..c251a57ee1 100644 --- a/recipes/economist.recipe +++ b/recipes/economist.recipe @@ -49,6 +49,8 @@ def process_node(node, html_parent): def load_article_from_json(raw, root): data = json.loads(raw)['props']['pageProps']['content'] # open('/t/raw.json', 'w').write(json.dumps(data, indent=2, sort_keys=True)) + if isinstance(data, list): + data = data[0] body = root.xpath('//body')[0] for child in tuple(body): body.remove(child) diff --git a/recipes/economist_free.recipe b/recipes/economist_free.recipe index a2113f1c2f..c251a57ee1 100644 --- a/recipes/economist_free.recipe +++ b/recipes/economist_free.recipe @@ -49,6 +49,8 @@ def process_node(node, html_parent): def load_article_from_json(raw, root): data = json.loads(raw)['props']['pageProps']['content'] # open('/t/raw.json', 'w').write(json.dumps(data, indent=2, sort_keys=True)) + if isinstance(data, list): + data = data[0] body = root.xpath('//body')[0] for child in tuple(body): body.remove(child)