zoukankan      html  css  js  c++  java
  • IPIP.net识别客户端真实访问地址,具体到国家,省,市

     
    这个IP库实测还是比较准确的,免费版的可以具体到国内城市,国外只能到国家名称,免费版的自己定期更新Ip数据库即可。

    以下为C#调用代码

     
    class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    //传入要查询的ip 和17monipdb.datx 下载的ip库所在位置
                    string address = IPAddress.FindIPAddress("1.198.219.205", @"D:开发资料资料CodeIP地址获取IPAddressIPAddressinDebug"); 
                    Console.WriteLine(address);
                }
                catch (IOException ioex)
                {
                    Console.WriteLine(ioex.StackTrace);
                }
                catch (IPv4FormatException ipex)
                {
                    Console.WriteLine(ipex.StackTrace);
                }
                Console.ReadKey(true);
            }
        }
        public class IPAddress
        {
            public static string FindIPAddress(string ip,string basePath)
            {
                string address = "";
                if (string.IsNullOrEmpty(ip))
                {
                    return address;
                }
                try
                {
                    string path = string.Format("{0}\{1}", basePath, "17monipdb.datx");
                    City city = new City(path);
                    string[] arr = city.find(ip);
                    if (arr != null && arr.Length > 0)
                    {
                        address = string.Join("-", arr);
                    }
                }
                catch (IOException ioex)
                {
                    Console.WriteLine(ioex.StackTrace);
                }
                catch (IPv4FormatException ipex)
                {
                    Console.WriteLine(ipex.StackTrace);
                }
                return address.TrimEnd("-".ToCharArray());
            }
        }


    IPIP.net官网在这 戳戳戳  
    ————————————————
    版权声明:本文为CSDN博主「皮皮虾大侠」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/Asa_Jim/article/details/94394612    是本人CSDN原创

     
    • 23
    • 00
    • 01
    • 02
    • 03
    • 04
    • 05
    • 06
    • 07
    • 08
    • 09
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 00
    • 01
    • 02
    • 03
    • 04
    • 05
    • 06
    • 07
    • 08
    • 09
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 00
    • 01
    • 02
    • 03
    • 04
    • 05
    • 06
    • 07
    • 08
    • 09
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
     
     
     
  • 相关阅读:
    CentOS搭建LAMP环境
    CentOS下为Apache部署Symantec SSL证书并实现强制https访问
    [Raspi]树莓派4B装机使用上手指南
    [FPGA]Verilog利用PWM调制完成RGB三色彩虹呼吸灯
    [FPGA]浅谈LCD1602字符型液晶显示器(Verilog)
    [FPGA]Verilog实现JK触发器组成的8421BCD码十进制计数器
    [FPGA]Verilog实现可自定义的倒计时器(24秒为例)
    [FPGA]Verilog实现8位串并转换器HC595
    [FPGA]Verilog实现寄存器LS374
    STM32F407之USART
  • 原文地址:https://www.cnblogs.com/DeepinCoding/p/11990138.html
Copyright © 2011-2022 走看看