Skip to main content

Provide some useful util functions and a tool (ip2region) for ip processing

Project description

iputil

Provide some useful util functions and a tool (ip2region) for ip processing.

Install

pip3 install iputil

Python usage

import iputil

# Get Region by IP
iputil.get_region("60.30.1.1")
# return string '中国|0|天津|天津|联通'

Although region data in this program will update with the @ip2region repo, or your can specify your own data source:

import iputil

# Set Region source
iputil.set_region_source(data_file="ip2region.db")

# Get Region by IP
iputil.get_region("60.30.1.1")
# return string '中国|0|天津|天津|联通'

Tools

An independent tool named ip2region will be install in your path.

Typing ip2region will start a prompt:

$ ip2region
ip> 192.168.0.1
[192.168.0.1]   0|0|0|内网IP|内网IP

ip> 60.30.1.1
[60.30.1.1]     中国|0|天津|天津|联通

ip> 120.100.0.1
[120.100.0.1]   中国|0|台湾|台北|0

ip> 8.8.8.8
[8.8.8.8]       美国|0|0|0|谷歌

ip> 
$ ip2region -h
usage: ip2region [-h] [-ip IP]

IP to Region

optional arguments:
  -h, --help       show this help message and exit
  -ip IP, --ip IP  Search specify IP

Reflink

Thanks to @ip2region.

Project details


Download files

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

Source Distribution

iputil-0.3.1.tar.gz (4.3 MB view details)

Uploaded Source

Built Distribution

iputil-0.3.1-py3.9.egg (4.3 MB view details)

Uploaded Source

File details

Details for the file iputil-0.3.1.tar.gz.

File metadata

  • Download URL: iputil-0.3.1.tar.gz
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for iputil-0.3.1.tar.gz
Algorithm Hash digest
SHA256 4c41642a113eb533696eb4b9370e86405857ac81687a2b236e3529ad99718676
MD5 fb5eb07d9147c0f4ab341c828df7987e
BLAKE2b-256 b119948778869f15a538408901e48117d591a5193f05c4c2ec24ff6c1fbd03bb

See more details on using hashes here.

File details

Details for the file iputil-0.3.1-py3.9.egg.

File metadata

  • Download URL: iputil-0.3.1-py3.9.egg
  • Upload date:
  • Size: 4.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for iputil-0.3.1-py3.9.egg
Algorithm Hash digest
SHA256 6735ee7541c225e99206cab517a021fc53d5bb7fd24ef6efbb0b029b347c25ee
MD5 9d051953b4523c62b5538d0fd5963949
BLAKE2b-256 f232d40f2b730ab46a597412e322eed106d20054b211c20f9501735e8b98fbe4

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