An offline tool to get country by IP
Project description
An offline tool to get country by IP
Requirements
- Python >= 3.6
- IP2Location™ LITE IP-COUNTRY-REGION-CITY Database
Installation
- Download IP2Location database for IPv4 from https://lite.ip2location.com/database/ip-country-region-city
- Install library:
pip install ip_country
Usage
>>> from pprint import pprint >>> from ip_country import IPCountry >>> ip = IPCountry('/path/to/ipdb.csv') >>> ip_data = ip.get_ip_data('13.73.96.0') >>> pprint(ip_data) {'city_name': 'Melbourne', 'country_code': 'AU', 'country_name': 'Australia', 'error': None, 'ip': '13.73.96.0', 'region_name': 'Victoria'} >>> ip_data = ip.get_ip_data('blah.73.96.0') >>> pprint(ip_data) {'error': "Only decimal digits permitted in 'blah' in 'blah.73.96.0'", 'ip': 'blah.73.96.0'}
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.
Built Distribution
Close
Hashes for ip_country-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d3cee970d88fd55314dc9c7af47ddb491ee791c52bb9d789912c8e3207b409e |
|
MD5 | 7a71352482bd3daefe017c3177add47b |
|
BLAKE2-256 | 64b789fb475397fbcf3f5d90537c839d25476c99fdd791afa1db5c4c2b66be45 |