首页 > 其他 > 详细

获取当前国家与ip地址

时间:2017-09-12 11:37:38      阅读:260      评论:0      收藏:0      [点我收藏+]

JS获取当前国家示例:

<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>
    <script>
        $(function () {
            var name = remote_ip_info["country"];
            document.getElementById("guojia").value = name;

        })
     </script>
<input style="display:none" id="guojia" name="country" value="" />

 

C#获取ip地址:

//获取当前IP
        public string GetIp()
        {
            System.Net.WebClient client = new System.Net.WebClient();
            client.Encoding = System.Text.Encoding.Default;
            string reply = client.DownloadString("http://www.ip138.com/ip2city.asp");
            int start = reply.IndexOf("[");
            int end = reply.IndexOf("]");
            return reply.Substring((start + 1), (end - start - 1));
        }

  

获取当前国家与ip地址

原文:http://www.cnblogs.com/lanke0/p/7509037.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!