PHP Capture Method:
1.<?php
2.function get_ip_place () {
3. $ip =file_get_contents ("http://fw.qq.com/ipaddress");
4. $ip =str_replace (' ",", $IP);
5. $ip 2=explode ("(", $IP);
6. $a =substr ($ip 2[1],0,-2);
7. $b =explode (",", $a);
8.return $b;
9.}
$ip =get_ip_place ();
11.print_r ($IP);
12.? >
JS get
Demo:http://blog.suiyidian.cn/texiao/ipd.html
Tencent's IP Address API interface address: http://fw.qq.com/ipaddress
The data format returned is: var ipdata = new Array ("114.218.183.139″," "," "Beijing");
Use JS code to make a fetch:
<script language= "javascript" type= "Text/javascript" src= "http://fw.qq.com/ipaddress" >
</script>
<script>document.write ("Your IP is:" +ipdata[0]+ ", From:" +ipdata[2]);
</script>
Tencent IP, turn UTF-8:
<script type= "Text/javascript" src= "http://fw.qq.com/ipaddress" charset= "gb2312" ></script>
$ ( Document). Ready (function () {
$ ("#ip"). Val (ipdata[0]);
$ ("#add"). Val (ipdata[2]);
}
Other ways to get:
Sina's IP address query interface: HTTP://INT.DPOOL.SINA.COM.CN/IPLOOKUP/IPLOOKUP.PHP?FORMAT=JS
Sina Multi-Region test method: http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=12.130.132.30
Sohu IP Address Query interface (default GBK): Http://pv.sohu.com/cityjson
Sohu IP Address Query interface (can be set code): Http://pv.sohu.com/cityjson?ie=utf-8
Sohu additional IP Address query interface: HTTP://TXT.GO.SOHU.COM/IP/SOIP