GeoIP look-ups
At times, it will be necessary for many applications to look-up the location of the IP addresses. For example, many website owners can be interested in tracking the location of their visitors and in classifying their IPs according to criteria, such as country, city, and so on. There is a third-party library called python-geoip, which has a robust interface for giving you the answer to your IP location query. This library is provided by MaxMind, which also provides the option for shipping a recent version of the Geolite2 database as the python-geoip-geolite2
package. This includes the GeoLite2 data created by MaxMind, which is available at www.maxmind.com under the creative commons Attribution-ShareAlike 3.0 Unported License. You can also buy a commercial license from their website.
Let's see an example of how to use this Geo-lookup library.:
import socket from geoip import geolite2 import argparse if __name__ == '__main__': # Setup commandline arguments parser = argparse...