Python Library
This module is a Python Library to support all IP2Location™ database products. It has been optimized for speed and memory utilization. Developers can use this API to query all IP2Location™ binary databases for applications written in Python.
IP2Location Python Library (478.44 kB)
Version: 4.0.0
Installation
- Download IP2Location C library at here.
- Decompress C library.
tar ip2location-c-x.x.x.tar.gz - Download and decompress Python library.
tar ip2location-python-x.x.x.tar.gz - Get into working directory.
cd ip2location-python-x.x.x - Edit setup.py to point library_dirs and include_dirs ponting to IP2Location C library folder.
- Start compilation.
python setup.py build && python setup.py install
*For MacOS X:
- Download IP2Location C library at here.
- Decompress C library.
tar ip2location-c-x.x.x.tar.gz - cd C-IP2Location-<version>/libIP2Location
- export CFLAGS=-I/usr/include/malloc
- gcc -arch i386 -arch x86_64 -arch ppc -c IP2Location.c iMath/imath.c
- gcc -arch i386 -arch x86_64 -arch ppc -dynamiclib -current_version 1.0 -o /usr/local/lib/libIP2Location.dylib IP2Location.o imath.o
- Download and decompress Python library.
tar ip2location-python-x.x.x.tar.gz - cd <path>/ip2location-python-<version>
- python setup.py build && python setup.py install
Sample Codes
import IP2Location;
IP2LocObj = IP2Location.IP2Location();
IP2LocObj.open("data/IP-COUNTRY-SAMPLE.BIN");
rec = IP2LocObj.get_all("19.5.10.1");
print rec.country_short
print rec.country_long
print rec.region
print rec.city
print rec.isp
print rec.latitude
print rec.longitude
print rec.domain
print rec.zipcode
print rec.timezone
print rec.netspeed
print rec.idd_code
print rec.area_code
print rec.weather_code
print rec.weather_name
print rec.mcc
print rec.mnc
print rec.mobile_brand
Sample Database (BIN)
Evaluation version of the database file having limited range of IP address information. You can query all IP addresses from 0.0.0.0 to 99.255.255.255 only.
- IP2Location™ DB1 Sample BIN database (167.92 kB)
- IP2Location™ DB2 Sample BIN database (33.91 MB)
- IP2Location™ DB3 Sample BIN database (7.01 MB)
- IP2Location™ DB4 Sample BIN database (39.73 MB)
- IP2Location™ DB5 Sample BIN database (10.14 MB)
- IP2Location™ DB6 Sample BIN database (43.17 MB)
- IP2Location™ DB7 Sample BIN database (44.40 MB)
- IP2Location™ DB8 Sample BIN database (48.07 MB)
- IP2Location™ DB9 Sample BIN database (11.93 MB)
- IP2Location™ DB10 Sample BIN database (50.73 MB)
- IP2Location™ DB11 Sample BIN database (12.18 MB)
- IP2Location™ DB12 Sample BIN database (51.04 MB)
- IP2Location™ DB13 Sample BIN database (10.77 MB)
- IP2Location™ DB14 Sample BIN database (51.74 MB)
- IP2Location™ DB15 Sample BIN database (13.19 MB)
- IP2Location™ DB16 Sample BIN database (54.06 MB)
- IP2Location™ DB17 Sample BIN database (13.92 MB)
- IP2Location™ DB18 Sample BIN database (58.54 MB)
- IP2Location™ DB19 Sample BIN database (49.63 MB)
- IP2Location™ DB20 Sample BIN database (59.93 MB)
