From d14b8c98acd3187274a285cf8fa912f63214b15c Mon Sep 17 00:00:00 2001 From: Jaric Kuo Date: Wed, 26 Oct 2022 09:29:14 +0800 Subject: [PATCH] fixed parser in different cases --- paser.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/paser.py b/paser.py index 8cac9aa..98efb59 100644 --- a/paser.py +++ b/paser.py @@ -19,8 +19,12 @@ def _parse_edgelist(resp): except: for data in resp.text.split('\r\n', -1): try: - edges.append(json.loads(data)[ - 'data']['node']['timeline_list_feed_units']['edges'][0]) + if 'timeline_list_feed_units' in json.loads(data)['data']['node']: + edges.append(json.loads(data)['data']['node']['timeline_list_feed_units']['edges'][0]) + elif 'timeline_feed_units' in json.loads(data)['data']['node']: + edges.append(json.loads(data)['data']['node']['timeline_feed_units']['edges'][0]) + else: + edges.append(json.loads(data)['data']['node']['timeline_list_feed_units']['edges'][0]) except: edges.append(json.loads(data)['data']) return edges