From 017474ad8a647054db88e05100c38f49ef3e38e5 Mon Sep 17 00:00:00 2001 From: Albert Nguyen Date: Thu, 17 Jan 2019 16:41:43 -0600 Subject: [PATCH] Added getJson --- urlscan.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/urlscan.py b/urlscan.py index 28ed5e3..d8f89d5 100644 --- a/urlscan.py +++ b/urlscan.py @@ -55,5 +55,23 @@ def getScreenshot(self): else: raise Exception('Non-200 respond: %s - %s' % screen.status_code,screen.text) + # def getReport(self): + # self.checkStatus() + # header = {'API-Key':self.apikey} + # result = requests.get("https://urlscan.io/result/%s/" % self.scanid,headers=header) + # if result.status_code == 200: + # return result.text + # else: + # raise Exception('Non-200 respond: %s - %s' % result.status_code,result.text) + + def getJson(self): + self.checkStatus() + header = {'API-Key':self.apikey} + json = requests.get("https://urlscan.io/api/v1/result/%s/" % self.scanid,headers=header) + if json.status_code == 200: + return json.json() + else: + raise Exception('Non-200 respond: %s - %s' % json.status_code,json.text) + def __repr__(self): - return "" % (self.url,self.useragent,self.referer,self.public,self.scanid) \ No newline at end of file + return "" % (self.url,self.useragent,self.referer,self.public,self.scanid)