API to access data from Sypex Geo IP database files from your Python code
Project description
http://github.com/idlesign/pysyge
What’s that
pysyge is an API to access data from Sypex Geo IP database files from your Python code.
For more information about Sypex Geo databases and their features please visit http://sypexgeo.net.
Direct DB link that might became broken over time:
Sypex Geo City DB - http://sypexgeo.net/files/SxGeoCity_utf8.zip
Requirements
Python 3.6+
Attention
This version of pysyge works with Sypex Geo DB version 2.2 or above.
The structure of a dictionary returned by GeoLocator.get_location() was preserved in a backward compatible manner as much as possible, yet it’s advised to update your code to use data from info sub dictionary.
This version of pysyge works with UTF-8 Sypex Geo Databases. Texts returned by pysyge are UTF-8.
Quickstart
Download Geo IP database file from http://sypexgeo.net/ (example below uses SxGeoCityMax.dat file).
Application sample
# Import all we need from pysyge module.
from pysyge import GeoLocator, MODE_BATCH, MODE_MEMORY
# Create GeoLocator object to access API
# from 'SxGeoCityMax.dat' using fast memory mode.
geodata = GeoLocator('SxGeoCityMax.dat', MODE_BATCH | MODE_MEMORY)
# Let's get some meta information.
print('DB version %s (%s)' % (geodata.get_db_version(), geodata.get_db_date()))
# Request geo information for 77.88.21.3 IP address.
# Getting detailed information, including region info.
location = geodata.get_location('77.88.21.3', detailed=True)
# Print out some lyrics.
# Most interesting data is under `info` in `city`, `country` and `region` dictionaries
print('%s (%s) calling. All the circuits are busy.' % (
location['info']['city']['name_en'], location['info']['country']['iso']))
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 Distribution
File details
Details for the file pysyge-1.2.0.tar.gz
.
File metadata
- Download URL: pysyge-1.2.0.tar.gz
- Upload date:
- Size: 23.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 462bfc4a82585c7eb0e01e2b4e664688a1f3101cd28f76ffb5f2e99fdf1e97c8 |
|
MD5 | d9cb5da264614a59d120b1f523433119 |
|
BLAKE2b-256 | a50fc2fe5d7b8e16c8b3dfa2d1fcccfe620c5aded52688132d16d7e300299b5e |
File details
Details for the file pysyge-1.2.0-py2.py3-none-any.whl
.
File metadata
- Download URL: pysyge-1.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62e6615726d05555861960dd6a4327862050d866f84706e97ae6e857c4653675 |
|
MD5 | d8b63dc9ae4d304e9ecb8a1b718536c4 |
|
BLAKE2b-256 | 71aed06c94f221f16fa054a56ae50980708ee51a15a461d004792c0232720401 |