2016-05-23 112 views
-4

我有興趣找到類似於www.ipchicken.com這樣做的訪客IP,有人可以告訴我如何做到這一點,並給我一個簡單的代碼?尋找訪客網絡IP地址

+1

這不是HTML,它是在服務器端完成的。你可以用任何服務器端語言來做到這一點。 –

+3

步驟1:選擇服務器支持的服務器端編程語言。步驟2:找到SO上的必然重複問題。例如[this](http://stackoverflow.com/questions/4489078/how-do-find-ip-address-of-client-using-perl)或[this](http://stackoverflow.com/questions/16575722/how-to-get-a-viewers-ip-address-with-python)或[this](http://stackoverflow.com/questions/8107856/how-to-determine-a-users-ip-address-節點內)或[this](http://stackoverflow.com/questions/11683246/get-ip-address-of-client-in-jsp) – Quentin

+3

[如何使用HTML檢測訪客的IP地址? ](http://stackoverflow.com/questions/8687642/how-to-detect-the-visitors-ip-address-using-html) –

回答

0

你將不得不使用這樣IPIFY

第三方API服務,使一個AJAX調用這個API,你會在響應中獲得IP。

$.ajax({ 
    url: "https://api.ipify.org?format=json" 
    type: "GET", 
    success: function (data) { 
     alert("IP: " + data); 
    } 
}); 
+0

儘管此鏈接可能回答問題,但最好在此處包含答案的基本部分,並提供供參考的鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 - [來自評論](/評論/低質量帖/ 12443524) –

+0

感謝您的信息。 :) –