[Chore] Rewrite the documentation examples for python 3
Issue
Python 2 is deprecated but all examples in the documentation are given for python 2 rather than for python 3.
Most people use python 3 and those still using python 2 should really move to python 3 now it is deprecated. Keeping the documentation for python 2 make no sense anymore.
Solution
Rewrite the documentation examples for python 3
Example
At https://shodan.readthedocs.io/en/latest/tutorial.html#searching-shodan
# Wrap the request in a try/ except block to catch errors try: # Search Shodan results = api.search('apache') # Show the results print('Results found: {}'.format(results['total'])) for result in results['matches']: print('IP: {}'.format(result['ip_str'])) print(result['data']) print('') except shodan.APIError, e: print('Error: {}'.format(e))
But except shodan.APIError, e: is python 2 only. With python 3 you will get the following error:
except shodan.APIError, e:
^
SyntaxError: invalid syntax
In python 3 you should write:
except shodan.APIError as e:
print('Error: {}'.format(e))
Fix tracking:
- [x] #115
- [x] #116
- [x] #117
The readthedocs still needs to be updated - https://shodan.readthedocs.io/en/latest/tutorial.html