Lookup country code (iso 3166) by IP address.
Project description
About
Lookup country code (iso 3166) by IP address.
Install
$ pip install ip2country
Or
$ python setup.py install
How to use
First: Implement IStore Interface
You must implement IStore interface in ip2country/interfaces.py.
There is a sample implementation in example/store. This implementation is stored all records on the system memory.
Second: Store the records
store = Store()
parser = Parser(store)
with open(RECORD_FILE) as fp:
parser.do(fp)
See examples/lookup.py:load for more detail.
Third: Lookup the IPAddress
store = Store()
record = store.lookup(IP_ADDRESS)
if record is None:
print('Record not found')
else:
print('{0} is allocated to {1}'.format(IP_ADDRESS, record.cc))
See examples/lookup.py:main for more detail.
Run the tests
$ tox
License
ip2country is licensed under the MIT LICENSE. See ./LICENSE.rst.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ip2country-0.1.1.tar.gz.
File metadata
- Download URL: ip2country-0.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26d112dc2f6a9ac834757282bef2674eccc4d552d2a05ffa0f1c7260059bcd3a
|
|
| MD5 |
db36d515061fd01bcfce6ee2b3ed5e1c
|
|
| BLAKE2b-256 |
e8051476031288bde6aaeccbbf797b802596801c35762d791a5ded50c6c5fac0
|
File details
Details for the file ip2country-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ip2country-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf3a383135779155ec2763ef2ce5c18ccda2d0a4d5c410a963475780a98f4fd1
|
|
| MD5 |
d9157021fc6f4d83d6ff689f395d50b3
|
|
| BLAKE2b-256 |
09b41abf8b76a84563a977e2cec8af328012ffdf5ed74a97cc6b584117f598ee
|
File details
Details for the file ip2country-0.1.1-py2-none-any.whl.
File metadata
- Download URL: ip2country-0.1.1-py2-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
798c56c0c8eaf3168c5eb2285994d808fb9d5cb48ba8b4a3d387cd464b7aeff8
|
|
| MD5 |
21d2c1f1d8744b2937b829c22be5c8bf
|
|
| BLAKE2b-256 |
a2e9cf87beec6dc28965218d973c30b721e30d23587f8f15dd5dcc9a6417a736
|