1.獲取IP地址的API
新浪的IP地址查詢接口:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js
新浪多地域測試方法:http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42
搜狐IP地址查詢接口(默認GBK):http://pv.sohu.com/cityjson
搜狐IP地址查詢接口(可設置編碼):http://pv.sohu.com/cityjson?ie=utf-8
有道xml
http://www.youdao.com/smartresult-xml/search.s?type=ip&q=115.156.238.114
淘寶IP地址庫API http://ip.taobao.com/service/getIpInfo.php?ip=[ip地址字串]
根據訪問者ip顯示對應地區的特定內容
根據訪問者ip,來讀ip庫或接口獲取地區,用該地區做篩選查詢
純真IP數據庫文件版 http://www.cz88.net/fox/
示例一:
1 $IpLocation = new IpLocation(); 2 $client = $IpLocation->getlocation(); 3 print_r($client);
示例二:
1 header("Content-type: text/html; charset=gbk"); 2 $IpLocation = new IpLocation('../qqwry/QQWry.Dat'); 3 $client = $IpLocation->getlocation('115.148.101.72'); 4 print_r($client);
相關說明
ShowIP.exe可以驗證程序,也可以更新。 此類要求提供純真IP數據庫,附件包里包含有此數據庫
如果電腦配置不好出現文件太大內存溢出問題,可以將ip庫換成mysql版
使用IPLook把QQWry.Dat文件解壓到IPData.txt文件,打開IPData.txt文件格式是這樣的
0.0.0.0 0.255.255.255 IANA保留地址 CZ88.NET
1.0.0.0 1.0.0.255 澳大利亞 CZ88.NET
1.0.1.0 1.0.3.255 福建省 電信
1.0.4.0 1.0.7.255 澳大利亞 CZ88.NET
建立ip數據庫表
1 CREATE TABLE `ip` ( 2 `StartIP` varchar(20) default '', 3 `EndIP` varchar(20) default NULL, 4 `Country` varchar(30) default NULL, 5 `Local` varchar(50) default NULL, 6 KEY `IP` USING BTREE (`StartIP`,`EndIP`) 7 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
MySQL的導入向導功能把IPData.txt文件的數據導入到ip數據表中
load data local infile 'data.txt' into 表名 (列名)
如何在MySQL中對ip比較
select * from ip where INET_ATON('119.253.32.42') between INET_ATON(startIp) and INET_ATON(endIp);
- iplocation.class.rar (2.9 MB)
- 描述: QQWry.Dat
- 下載次數: 42
- IpLocationApi.rar (2.6 MB)
- 下載次數: 3