Skip to content

Instantly share code, notes, and snippets.

@achillean
Created June 12, 2014 23:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save achillean/f953cb917a7eb2a9f81d to your computer and use it in GitHub Desktop.
Save achillean/f953cb917a7eb2a9f81d to your computer and use it in GitHub Desktop.
Basic code template for accessing the Shodan Streaming API using Python
#!/usr/bin/env python
#
# shodan-stream.py
# Read a firehose/ stream of 1% of the data that Shodan collects in real-time.
#
# WARNING: This script only works with people that have a subscription API plan!
# And by default the Streaming API only returns 1% of the data that Shodan gathers.
# If you wish to have more access please contact us at support@shodan.io for pricing
# information.
#
# Author: achillean
import shodan
import sys
# Configuration
API_KEY = 'YOUR API KEY'
try:
# Setup the api
api = shodan.Shodan(API_KEY)
for banner in api.stream.banners():
print banner
except Exception, e:
print 'Error: %s' % e
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment