From 2bb3ba127718f711dd512c538cab8abd012d3a2b Mon Sep 17 00:00:00 2001 From: slixperi Date: Mon, 23 Dec 2019 11:35:38 -0500 Subject: [PATCH] added block to catch 404 or accounts not found --- reddit-analyzer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/reddit-analyzer.py b/reddit-analyzer.py index d220304..2d33f6d 100644 --- a/reddit-analyzer.py +++ b/reddit-analyzer.py @@ -31,7 +31,13 @@ # fetch profile data r3 = requests.get('https://www.reddit.com/user/'+username+'/about.json', headers=headers) -userdata = r3.json()['data'] + +# if not found or 404 returned, exit +if (r3.json()['message'] == 'Not Found' or r1.json()['error'] == 404): + print("No Account Details Found, 404 Received") + exit() +else: + userdata = r3.json()['data'] # fetch comments while True: @@ -187,4 +193,4 @@ def timeGraph(timelist): print(' ') getComments() print(' ') -timeGraph(timelist) \ No newline at end of file +timeGraph(timelist)