pip install GeoIP Copy PIP instructions , Released: Aug 22, 2014 , View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery ,Status: all systems operational
With pip:
$ pip install GeoIP
From source:
$ python setup.py build $ python setup.py install
extension = php_geoip.dll
Example usage:
< ? php
/**
* @author tutorialspots.com
* @copyright 2016
*/
print_r(geoip_record_by_name('tutorialspots.com'));
?
>
If you also want the free MaxMind Geolite2 database you can in addition:,If you have installed the python-geoip-geolite2 package you can start using the GeoIP database right away:,Provides access to the geolite2 cities database. In order to use this database the python-geoip-geolite2 package needs to be installed.,The python-geoip-geolite2 package includes GeoLite2 data created by MaxMind, available from maxmind.com under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
pip install python - geoip
pip install python - geoip - geolite2
>>> from geoip
import geolite2
>>>
match = geolite2.lookup('17.0.0.1') >>>
match is not None
True
>>>
match.country 'US' >>>
match.continent 'NA' >>>
match.timezone 'America/Los_Angeles' >>>
match.subdivisions
frozenset(['CA'])
>>> from geoip
import open_database
>>>
db = open_database('path/to/my.mmdb')
from geoip
import open_database
with open_database('data/GeoLite2-City.mmdb') as db:
match = db.lookup_mine()
print 'My IP info:', match