diff --git a/etherscan/client.py b/etherscan/client.py index 08928ce..af06eaf 100644 --- a/etherscan/client.py +++ b/etherscan/client.py @@ -1,5 +1,4 @@ import requests -import json import collections # Assume user puts his API key in the api_key.json file under variable name "key" @@ -82,11 +81,17 @@ def connect(self): try: req = self.http.get(self.url) except requests.exceptions.ConnectionError: - return "Connection refused" + print("Connection refused") + exit() + if req.status_code == 200: # Check for empty response if req.text: - return json.loads(req.text) + if req.json()['status'] == '1': + return req.json() + else: + print(req.json()['message']) + exit() else: print("Invalid Request") exit()