Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions etherscan/client.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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()
Expand Down