Skip to content

Commit b158c2d

Browse files
committed
Fixed issue corpetty#14:
- Checks that the status code is 1. If it's not then the program exits and returns the message field to the user. Incidentals: - I was using `json.loads()` to turn the respone text into json. However, the request object has a method which returns the json from the response. Thus, I have switched to using the `.json()` method.
1 parent 2997d7d commit b158c2d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

etherscan/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import requests
2-
import json
32
import collections
43

54
# Assume user puts his API key in the api_key.json file under variable name "key"
@@ -88,7 +87,11 @@ def connect(self):
8887
if req.status_code == 200:
8988
# Check for empty response
9089
if req.text:
91-
return json.loads(req.text)
90+
if req.json()['status'] == '1':
91+
return req.json()
92+
else:
93+
print(req.json()['message'])
94+
exit()
9295
else:
9396
print("Invalid Request")
9497
exit()

0 commit comments

Comments
 (0)