![](/img/trans.png)
[英]Java and GeoLite database: How to use GeoLiteCity.dat in a production way?
[英]How to use GeoLite City, how to obtain startIpNum and endIpNum
好吧,我從http://dev.maxmind.com/geoip/legacy/geolite/ GeoLite City
數據庫下載了。
值在GeoLiteCity-Blocks.csv
startIpNum,endIpNum,locId
"16777216","16777471","17"
但是我不知道如何將ips轉換為這些startIpNum和endIpNum范圍。 我在他們的網站上找不到,他們鏈接到這里
將ip v4轉換為this的算法是什么?
非常感謝你
這取決於您使用哪種編程語言。
在php中,您可以使用ip2long和long2ip來處理ips。
string long2ip ( string $proper_address )
The function long2ip() generates an Internet address in dotted format (i.e.: aaa.bbb.ccc.ddd) from the proper address representation.
http://php.net/manual/en/function.long2ip.php
您提供的ips示例: http : //sandbox.onlinephpfunctions.com/code/3decd3d4818a02d65b9a80cf2dc1c70297b0d2d5
如果您使用的是Python,則可以使用
>>> import socket, struct
>>> socket.inet_ntoa(struct.pack('!L', 16777216))
'1.0.0.0'
從整數轉換為IP字符串。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.