From 3f848ce2c5af2c61b16d6f225820e5c2298e7af4 Mon Sep 17 00:00:00 2001 From: daniel-Jones Date: Fri, 14 Jul 2017 10:56:15 +0930 Subject: no longer commiting utf8 encoded string --- main.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 9ac0848..f930004 100644 --- a/main.py +++ b/main.py @@ -21,9 +21,13 @@ def getjson(url): args: url = url to request data from ''' - f = urllib.request.urlopen(url); - content = f.read(); - f.close(); + try: + f = urllib.request.urlopen(url); + content = f.read(); + f.close(); + except urllib.error.URLError: + print("error getting json, api down probably, try later"); + raise SystemExit; return content; def dbconnect(): @@ -163,7 +167,7 @@ def collectbants(): print("message not logged, logging"); query = {"author": author, "channel": j['channels'][x]['name'], - "message": str(data['messages'][i]['text'].encode('utf8')), + "message": str(data['messages'][i]['text']), "timestamp": data['messages'][i]['ts']}; message_id = messagedb.insert_one(query).inserted_id; else: -- cgit v1.2.3