于正洋 4 years ago
parent
commit
7b5432982e

+ 1 - 0
Azylee.Utils/Azylee.YeahWeb/Azylee.YeahWeb.csproj

@@ -57,6 +57,7 @@
     <Compile Include="ExtWebAPI\BingWebAPI\WallpaperUtils\WallpaperTool.cs" />
     <Compile Include="ExtWebAPI\BingWebAPI\WallpaperUtils\WallpaperTool.cs" />
     <Compile Include="ExtWebAPI\IPAddressAPI\PublicIPAddressTool.cs" />
     <Compile Include="ExtWebAPI\IPAddressAPI\PublicIPAddressTool.cs" />
     <Compile Include="ExtWebAPI\IPAddressAPI\PublicIPAddressModel.cs" />
     <Compile Include="ExtWebAPI\IPAddressAPI\PublicIPAddressModel.cs" />
+    <Compile Include="ExtWebAPI\IPCNAPI\IPCNTool.cs" />
     <Compile Include="FTPUtils\FTPTool.cs" />
     <Compile Include="FTPUtils\FTPTool.cs" />
     <Compile Include="HttpUtils\MethodUtils\ExtendUtils\HeaderTool.cs" />
     <Compile Include="HttpUtils\MethodUtils\ExtendUtils\HeaderTool.cs" />
     <Compile Include="HttpUtils\MethodUtils\GetUtils\GetToolPlus.cs" />
     <Compile Include="HttpUtils\MethodUtils\GetUtils\GetToolPlus.cs" />

+ 36 - 0
Azylee.Utils/Azylee.YeahWeb/ExtWebAPI/IPCNAPI/IPCNTool.cs

@@ -0,0 +1,36 @@
+using Azylee.Core.DataUtils.StringUtils;
+using Azylee.Jsons;
+using Azylee.YeahWeb.HttpUtils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Text;
+
+namespace Azylee.YeahWeb.ExtWebAPI.IPCNAPI
+{
+    public static class IPCNTool
+    {
+        const string URL = "https://www.ip.cn/api/index?ip=&type=0";
+
+        /// <summary>
+        /// 获取IP地址信息
+        /// </summary>
+        /// <returns></returns>
+        public static Tuple<string, string> Get()
+        {
+            try
+            {
+                CookieCollection cookie = new CookieCollection();
+                string rss1 = HttpToolPlus.Get(URL, ref cookie);
+                Dictionary<string, string> model = Json.String2Object<Dictionary<string, string>>(rss1);
+
+                string ip = "", address = "";
+                if (model.TryGetValue("ip", out string _ip)) ip = _ip;
+                if (model.TryGetValue("address", out string _address)) address = _address;
+                return new Tuple<string, string>(ip, address);
+            }
+            catch (Exception e) { return null; }
+        }
+    }
+}

+ 4 - 0
Azylee.Utils/Tests/Test.YeahWeb/Program.cs

@@ -2,6 +2,8 @@
 using Azylee.Jsons;
 using Azylee.Jsons;
 using Azylee.YeahWeb.BaiDuWebAPI.dwz;
 using Azylee.YeahWeb.BaiDuWebAPI.dwz;
 using Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI;
 using Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI;
+using Azylee.YeahWeb.ExtWebAPI.IPAddressAPI;
+using Azylee.YeahWeb.ExtWebAPI.IPCNAPI;
 using System;
 using System;
 
 
 namespace Test.YeahWeb
 namespace Test.YeahWeb
@@ -17,6 +19,8 @@ namespace Test.YeahWeb
 
 
 
 
             var s = IPLocationTool.GetLocation();
             var s = IPLocationTool.GetLocation();
+           var st =  PublicIPAddressTool.GetPublicIP();
+            var sss = IPCNTool.Get();
             if (s != null)
             if (s != null)
             {
             {