Skip to main content

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

  1. Download IP2Location database for IPv4 from https://lite.ip2location.com/database/ip-country-region-city

  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ip_country-1.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file ip_country-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ip_country-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.3

File hashes

Hashes for ip_country-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d3cee970d88fd55314dc9c7af47ddb491ee791c52bb9d789912c8e3207b409e
MD5 7a71352482bd3daefe017c3177add47b
BLAKE2b-256 64b789fb475397fbcf3f5d90537c839d25476c99fdd791afa1db5c4c2b66be45

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page