Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'shodan': self.base_url,
'exploits': self.base_exploits_url,
}.get(service, 'shodan')
# Send the request
try:
data = urlopen(base_url + function + '?' + urlencode(params)).read().decode('utf-8')
except:
raise WebAPIError('Unable to connect to Shodan')
# Parse the text from JSON to a dict
data = loads(data)
# Raise an exception if an error occurred
if data.get('error', None):
raise WebAPIError(data['error'])
# Return the data
return data
"""
# Add the API key parameter automatically
params['key'] = self.api_key
# Determine the base_url based on which service we're interacting with
base_url = {
'shodan': self.base_url,
'exploits': self.base_exploits_url,
}.get(service, 'shodan')
# Send the request
try:
data = urlopen(base_url + function + '?' + urlencode(params)).read().decode('utf-8')
except:
raise WebAPIError('Unable to connect to Shodan')
# Parse the text from JSON to a dict
data = loads(data)
# Raise an exception if an error occurred
if data.get('error', None):
raise WebAPIError(data['error'])
# Return the data
return data