Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

README.md

重要提示

datx格式将全面升级为ipdb格式 IPDB格式解析代码

ipdb 格式优点

  • 可同时支持IPv4与IPv6
  • 可同时支持中文与英文
  • 查询性能大幅度提高

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"))

About

IPIP.net官方支持的解析datx格式的Python代码

Resources

License

Releases

No releases published

Packages

No packages published

Languages

You can’t perform that action at this time.