zoukankan      html  css  js  c++  java
  • C#获取*IP地址;C#获取所在IP城市地址

    public static string GetIP()
            {
                using (var webClient = new WebClient())
                {
                    try
                    {
                        var temp = webClient.DownloadString("http://iframe.ip138.com/ic.asp");
                        var ip = Regex.Match(temp, @"[(?<ip>d+.d+.d+.d+)]").Groups["ip"].Value;
                        return !string.IsNullOrEmpty(ip) ? ip : null;
                    }
                    catch (Exception ex)
                    {
                        return ex.Message;
                    }
                }
            }
    

      

    //表单验证
            $(function () {
    
    
                var ip = $.trim($("#hidLocalIp").val()); // "218.4.255.91";
                $.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=' + ip, function (_result) {
                    if (remote_ip_info.ret == "1") {
                        $("#hidArea").val(ip + ";" + remote_ip_info.country + ";" + remote_ip_info.province + ";" + remote_ip_info.city + ";" + remote_ip_info.isp + ";");
                        //alert(ip + ";" + remote_ip_info.country + ";" + remote_ip_info.province + ";" + remote_ip_info.city + ";" + remote_ip_info.isp + ";"); 
                    }
                }); 
            });
    

      

  • 相关阅读:
    线程
    进程2
    进程
    socketserver
    黏包
    初始网络编程
    模块
    super
    mro c3算法
    日志固定格式
  • 原文地址:https://www.cnblogs.com/kinpauln/p/4150556.html
Copyright © 2011-2022 走看看