IPIP.net官方支持的解析datx格式的Python代码
Switch branches/tags
Nothing to show
Clone or download
Latest commit 8bcf2c3 Jul 19, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
datx update code Mar 7, 2018
.gitignore Initial commit Mar 4, 2018
LICENSE Initial commit Mar 4, 2018
README.md update Jul 19, 2018
example.py update code Mar 7, 2018
setup.py update code Mar 7, 2018

README.md

Python Parse datx file

Installing

pip install ipip-datx

Code Example


import datx
c = datx.City("/path/to/mydata4vipday2.datx")
print(c.find("8.8.8.258"))
print(c.find("255.255.255.255"))
  

Output for IP 8.8.8.8 Results


[
"GOOGLE.COM", // country_name
"GOOGLE.COM", // region_name
"",             // city_name
"google.com", // owner_domain
"level3.com", // isp_domain
"", // latitude
"", // longitude
"", // timezone
"", // utc_offset
"", // china_admin_code
"", // idd_code
"", // country_code
"", // continent_code
"IDC", // idc
"", // base_station
"", // country_code3
"", // european_union
"", // currency_code
"", // currency_name
"ANYCAST" // anycast
]
  


# For China district datx file
d = datx.District("/path/to/quxian.datx")
print(d.find("123.121.117.72"))

# For China Base Station datx file
d = datx.BaseStation("/path/to/station_ip.datx")
print(d.find("223.221.121.0"))