IP²éѯ½Ó¿ÚµØÖ·¿â¼°Æä¼òµ¥Ê¹Ó÷½·¨

µ¼Óï ÕâÀï·ÖÏí¼¸¸öÄ¿Ç°ÄÜÓõģ¬´ó¼Ò¸÷È¡ËùÐè°É¡£Ò»¡¢ÌÔ±¦IPµØÖ·¿â* ÍøÖ·£ºhttp: ip taobao com * ÇëÇó½Ó¿Ú£¨GET£©£ºhttp: ip taobao com service getIpInfo php?ip=[ipµØÖ·]* ·µ»ØÊý¾Ý¸ñʽ£º£¨json¸ñʽµÄ£©¹ú¼Ò
ÕâÀï·ÖÏí¼¸¸öÄ¿Ç°ÄÜÓõģ¬´ó¼Ò¸÷È¡ËùÐè°É¡£

Ò»¡¢ÌÔ±¦IPµØÖ·¿â

*. 꿅᣼http://ip.taobao.com/

*. ÇëÇó½Ó¿Ú£¨GET£©£ºhttp://ip.taobao.com/service/getIpInfo.php?ip=[ipµØÖ·]

*. ·µ»ØÊý¾Ý¸ñʽ£º£¨json¸ñʽµÄ£©¹ú¼Ò ¡¢Ê¡£¨×ÔÖÎÇø»òֱϽÊУ©¡¢ÊУ¨ÏØ£©¡¢ÔËÓªÉÌ¡£ÀýÈ磺

{"code":0,"data":{"ip":"210.75.225.254","country":"\u4e2d\u56fd","area":"\u534e\u5317",
"region":"\u5317\u4eac\u5e02","city":"\u5317\u4eac\u5e02","county":"","isp":"\u7535\u4fe1",
"country_id":"86","area_id":"100000","region_id":"110000","city_id":"110000",
"county_id":"-1","isp_id":"100017"}}

×¢£ºÆäÖÐcodeµÄÖµµÄº¬ÒåΪ£¬0£º³É¹¦£¬1£ºÊ§°Ü¡£

*.  ÌÔ±¦IP½Ó¿ÚʹÓÃʾÀýPHP°æ£º

<?php
$ip=get_ip_data();
function get_ip_data(){
	$ip=file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".get_client_ip());
	$ip = json_decode($ip);
	if($ip->code){
		return false;
	}
	$data = (array) $ip->data;
	print_r($data);//return $data;
}

//È¡¿Í»§¶Ë ip
function get_client_ip(){
	if (isset($_SERVER['HTTP_CLIENT_IP']) and !empty($_SERVER['HTTP_CLIENT_IP'])){
		return $_SERVER['HTTP_CLIENT_IP'];
	}
	if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) and !empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
		return strtok($_SERVER['HTTP_X_FORWARDED_FOR'], ',');
	}
	if (isset($_SERVER['HTTP_PROXY_USER']) and !empty($_SERVER['HTTP_PROXY_USER'])){
		return $_SERVER['HTTP_PROXY_USER'];
	}
	if (isset($_SERVER['REMOTE_ADDR']) and !empty($_SERVER['REMOTE_ADDR'])){
		return $_SERVER['REMOTE_ADDR'];
	} else {
		return "0.0.0.0";
	}
}
?>

¶þ¡¢ÐÂÀËIPµØÖ·²éѯ½Ó¿Ú

*. ÇëÇó½Ó¿Ú(GET)£ºhttp://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=[ipµØÖ·]

×¢£º²ÎÊýformat¿ÉÉèÖ÷µ»Ø¸ñʽ£ºjs/json£»²ÎÊýip¿ÉÑ¡²éѯIP£»

*.  ·µ»Ø¸ñʽÈçÏ£º

var remote_ip_info = {"ret":1,"start":"125.40.0.0","end":"125.40.111.255","country":"\u4e2d\u56fd","province":"\u6cb3\u5357","city":"\u90d1\u5dde","district":"","isp":"\u8054\u901a","type":"","desc":""};

ÏÂÃæµÄʵÀýÓõ½ÁËJQueryϵÄgetScript()·½·¨£º

<div id="sina_ip_info"></div>
<script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
var uip = '8.8.8.8';
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip='+uip, function(_result){
	var ipData = ""; //³õʼ»¯±£´æÄÚÈݱäÁ¿
	if (remote_ip_info.ret == '1'){
		ipData += "IP ÏêϸÐÅÏ¢£º<br>";
		ipData += "IP£º" + uip + "<br>";
		ipData += "¹ú¼Ò£º" + remote_ip_info.country + "<br>";
		ipData += "Ê¡·Ý£º" + remote_ip_info.province + "<br>";
		ipData += "³ÇÊУº" + remote_ip_info.city + "<br>";
		ipData += "Çø£º" + remote_ip_info.district + "<br>";
		ipData += "ISP£º" + remote_ip_info.isp + "<br>";
		ipData += "ÀàÐÍ£º" + remote_ip_info.type + "<br>";
		ipData += "ÆäËû£º" + remote_ip_info.desc + "<br>";
		$("#sina_ip_info").html(ipData); //ÏÔʾ´¦ÀíºóµÄÊý¾Ý
	} else {
		alert('´íÎó', 'ûÓÐÕÒµ½Æ¥ÅäµÄ IP µØÖ·ÐÅÏ¢£¡');
	}
});
</script>

Èý¡¢ËѺüIPµØÖ·²éѯ½Ó¿Ú£¨Ä¬ÈϱàÂëGBK£©

*. ÇëÇó½Ó¿Ú(GET)£ºhttp://pv.sohu.com/cityjson?ie=utf-8

ËÄ¡¢Ì«Æ½ÑóIPµØÖ·¿âAPI½Ó¿Ú

*. ÇëÇó½Ó¿Ú(GET)£ºhttp://whois.pconline.com.cn/?ip=[ipµØÖ·×Ö·û´®]

µ÷Ó÷½·¨·Ç³£·á¸»£¬Ìṩ¶àÖÖJSǶÈëµ÷Óá£

http://www.aseoe.com/ true IP²éѯ½Ó¿ÚµØÖ·¿â¼°Æä¼òµ¥Ê¹Ó÷½·¨ http://www.aseoe.com/show-12-695-1.html report <£¿php echo strlen($content) / 2; ?> ÕâÀï·ÖÏí¼¸¸öÄ¿Ç°ÄÜÓõģ¬´ó¼Ò¸÷È¡ËùÐè°É¡£Ò»¡¢ÌÔ±¦IPµØÖ·¿â* ÍøÖ·£ºhttp: ip taobao com * ÇëÇó½Ó¿Ú£¨GET£©£ºhttp: ip taobao com service getIpInfo php?ip=[ipµØÖ·]* ·µ»ØÊý¾Ý¸ñʽ£º£¨json¸ñʽµÄ£©¹ú¼Ò
TAG:ip ½Ó¿Ú
±¾Õ¾»¶Ó­ÈκÎÐÎʽµÄתÔØ£¬µ«ÇëÎñ±Ø×¢Ã÷³ö´¦£¬×ðÖØËûÈËÀͶ¯³É¹û
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-12-695-1.html

[Ç°¶Ë²å¼þÍƼö] Plugin

1 2 3 4
  • jQueryʵÏÖÖð×ÖÖð¾äÏÔʾ²å¼þl-by-l.min.js
  • jQuery´ø·½Ïò¸ÐÖªµÄÊó±ê»¬¹ýͼƬ±ß¿òÌØЧ²å¼þ
  • jQuery HotKeys¼àÌý¼üÅÌ°´ÏÂʼþkeydown²å¼þ
  • ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
webÇ°¶Ë¿ª·¢
°®Ë¼×ÊÔ´Íø Copyright 2012-2014 Www.Aseoe.Com All rights reserved.(½úICP±¸13001436ºÅ-1)