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)