Fix error when input Invalid ID

This commit is contained in:
Moe Poi ~ 2020-04-12 16:18:41 +07:00
parent 39ae303a68
commit 65a693515f

View file

@ -17,10 +17,9 @@ class QuintalGrabber:
self.host = "https://quintal.id" self.host = "https://quintal.id"
self.id = str(id) self.id = str(id)
self.endpoint = "/id/api/initial_data/{}/?format=json".format(self.id) self.endpoint = "/id/api/initial_data/{}/?format=json".format(self.id)
try: self.req = requests.get(self.host + self.endpoint)
self.req = requests.get(self.host + self.endpoint) self.data = json.loads(self.req.text)
self.data = json.loads(self.req.text) if "status" in self.data:
except:
print ("Invalid ID") print ("Invalid ID")
sys.exit() sys.exit()