1. 搜狐IP地址查詢接口(可設置編碼)javascript
<html>
<head>
<meta charset="utf-8">
<title>使用搜狐接口獲取客戶端IP地址</title>
</head>
<body>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
document.write(returnCitySN["cip"]+','+returnCitySN["cname"])
</script>
</body>
</html>php
二、新浪提供接口,經過網絡IP查看城市信息html
<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>java
var city = remote_ip_info['city'];json
3.太平洋IP地址庫API接口微信
比較全面的API:http://whois.pconline.com.cn/?ip=0.0.0.0#tabs-3網絡
<HTML>
<HEAD>
<TITLE>GetLocalIP</TITLE>
</HEAD>
<BODY>
您的位置信息是:<span id="idTestJson"></span><br/>
<script>
function testJson(obj) {
document.getElementById("idTestJson").innerHTML = "ip["+obj.ip+"]省["+obj.pro+"] 市["+obj.city+"] 區["+obj.region+"]";
}
</script>
<script src="http://whois.pconline.com.cn/ipJson.jsp?callback=testJson"></script>
</BODY>
</HTML>jsp
4. 國外freegeoip.net ,IP地址查詢接口編碼
$.getJSON("http://freegeoip.net/json/",
function(obj){
alert(obj.city+" "+obj.country_code+" "+obj.ip);
)spa
若有BUG或者須要jar包,加我微信!