Looking at these SHODAN docs I'm not sure I understand why I am only getting the first port details returned when I run the script. When I look in the web interface I can see there are multiple ports/services detected for some of the devices...
http://shodan.readthedocs.io/en/latest/tutorial.html#connect-to-the-api
#!/usr/bin/python
import shodan
SHODAN_API_KEY = "xxxxxxx"
api = shodan.Shodan(SHODAN_API_KEY)
try:
results = api.search('ics country:"US"')
for item in results['matches']:
print """
Port: %s
Banner: %s
""" % (item['port'], item['data'])
except shodan.APIError, e:
print 'Error: %s' % e