From fe3a0f3e07d9db8234f78e78f2dd40d4775c7430 Mon Sep 17 00:00:00 2001 From: aazhou Date: Sat, 24 Jun 2023 17:27:18 +0800 Subject: [PATCH] fix bug --- monitors/large_transfer.py | 20 +++++++++++--------- test.py | 3 +-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/monitors/large_transfer.py b/monitors/large_transfer.py index 847d57d..f8e8b04 100644 --- a/monitors/large_transfer.py +++ b/monitors/large_transfer.py @@ -6,7 +6,7 @@ import time import tg import traceback import logging - +import json def run(): try: @@ -16,12 +16,13 @@ def run(): url = f'https://api.whale-alert.io/v1/transactions?api_key={settings.whaleAlert_apikey}&start={start_ts}&min_value={settings.whaleAlert_max_limit}' headers = {'Accept': 'application/json'} - resp = requests.get(url, headers=headers).json() - - print(resp) - if resp['result'] == "success": - if 'transactions' in resp: - data = resp['transactions'] + resp = requests.get(url, headers=headers).text + data = json.loads(resp) + + print(data) + if data['result'] == "success": + if 'transactions' in data: + data = data['transactions'] for ts in data: if ts['to']['owner_type'] == 'exchange': @@ -38,8 +39,9 @@ def run(): tg.send_message(settings.chat_id, content) else: - print(resp['message']) - tg.send_message(settings.chat_id, resp['message']) + print(data) + tg.send_message(settings.chat_id, data['message']) except: + print(resp) logging.error(traceback.format_exc()) tg.send_message(settings.chat_id, traceback.format_exc()) \ No newline at end of file diff --git a/test.py b/test.py index 392da14..91e4bdc 100644 --- a/test.py +++ b/test.py @@ -5,5 +5,4 @@ import datetime as dt import monitors.large_transfer as lt from binance.spot import Spot -symbols = bn.symbols() -print(symbols) \ No newline at end of file +lt.run() \ No newline at end of file