Skip to content

Commit

Permalink
Separate shodanapi to manage calls to shodan
Browse files Browse the repository at this point in the history
  • Loading branch information
stavinski committed Mar 16, 2022
1 parent 7b3487e commit 04f6426
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions shodanapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from shodan import Shodan, APIError

class ShodanAPI(object):

def __init__(self, api_key):
self.api = Shodan(api_key)

def test(self):
try:
return True, self.api.info()
except APIError as e:
return False, e

def host(self, ip):
try:
return True, ip, self.api.host(ip)
except APIError as e:
return False, ip, e

0 comments on commit 04f6426

Please sign in to comment.