1

I'm trying to print out a full result list for a specific query I am performing, in the format IP:PORT. However it only prints a partial amount.

results['total'] prints 1799 (which is also the result amount when the search is performed on the Shodan website), however when printing the actual matches out, it only prints 99 results.

It probably is something elementary such as not showing all the result pages. I have a Shodan educational account.

from shodan import Shodan

api = Shodan('APIKEY')

# Search Shodan
results = api.search('SearchQuery')

# Results found: 1799 
print('Results found: {}'.format(results['total']))

# Prints 99 results. 
for result in results['matches']:
    print(str(result['ip_str']) + ":" + str(result['port']))

Expected: 1799 results Actual: 100 results

Thanks in advance!

4

2 回答 2

1

Shodan only returns the first page which contains 100 results, any further queries for pages beyond will cost 1 query credit.

To get more pages:

api.search('SearchQuery', page=2) etc...

于 2019-01-01T02:41:52.673 回答
1

According to the docs, this is working as intended:

Stepping through the code, we first call the Shodan.search() method on the api object which returns a dictionary of result information. We then print how many results were found in total, and finally loop through the returned matches and print their IP and banner. Each page of search results contains up to 100 results.

The documentation is in this pdf: https://media.readthedocs.org/pdf/shodan/latest/shodan.pdf

于 2019-01-01T03:06:04.120 回答