Browse Source

webtool update

yuzhengyang 1 year ago
parent
commit
77a42f4fc3

+ 18 - 0
Azylee.Utils/Azylee.YeahWeb/ExtWebAPI/IPAddressAPI/PublicIPAddressTool.cs

@@ -14,6 +14,8 @@ namespace Azylee.YeahWeb.ExtWebAPI.IPAddressAPI
     public class PublicIPAddressTool
     {
         const string URL = "http://pv.sohu.com/cityjson?ie=utf-8";
+        const string URL_IP = "https://www.ipplus360.com/getIP";
+        const string URL_LOC = "https://www.ipplus360.com/getLocation";
 
         /// <summary>
         /// 获取公网IP地址API
@@ -42,5 +44,21 @@ namespace Azylee.YeahWeb.ExtWebAPI.IPAddressAPI
             }
             return null;
         }
+
+        public static string GetIp()
+        {
+            string ip = "";
+            try
+            {
+                Dictionary<string, string> keyValuePairs = HttpTool.Get<Dictionary<string, string>>(URL_IP);
+            }catch(Exception ex) { }
+            return ip;
+        }
+
+        public static string GetLocation()
+        {
+            string location = "";
+            return location;
+        }
     }
 }

+ 1 - 1
Azylee.Utils/Azylee.YeahWeb/ExtWebAPI/IPCNAPI/IPCNTool.cs

@@ -22,7 +22,7 @@ namespace Azylee.YeahWeb.ExtWebAPI.IPCNAPI
             try
             {
                 CookieCollection cookie = new CookieCollection();
-                string rss1 = HttpToolPlus.Get(URL, ref cookie);
+                string rss1 = HttpToolPlus.Get(URL, ref cookie, Encoding.UTF8);
                 Dictionary<string, string> model = Json.String2Object<Dictionary<string, string>>(rss1);
 
                 string ip = "", address = "";

+ 2 - 2
Azylee.Utils/Azylee.YeahWeb/HttpUtils/HttpToolPlus.cs

@@ -10,9 +10,9 @@ namespace Azylee.YeahWeb.HttpUtils
 {
     public class HttpToolPlus
     {
-        public static string Get(string url, ref CookieCollection cookie, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = false, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
+        public static string Get(string url, ref CookieCollection cookie, Encoding encoding= null, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = false, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
         {
-            return GetToolPlus.Get(url, ref cookie, headers = null, contentType, autoRedirect, keepAlive, userAgent);
+            return GetToolPlus.Get(url, ref cookie, encoding, headers, contentType, autoRedirect, keepAlive, userAgent);
         }
         public static string Post(string url, ref CookieCollection cookie, Dictionary<string, string> data = null, Encoding encoding = null, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = true, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
         {

+ 2 - 2
Azylee.Utils/Azylee.YeahWeb/HttpUtils/MethodUtils/GetUtils/GetToolPlus.cs

@@ -11,7 +11,7 @@ namespace Azylee.YeahWeb.HttpUtils.MethodUtils.GetUtils
 {
     internal static class GetToolPlus
     {
-        internal static string Get(string url, ref CookieCollection cookie, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = false, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
+        internal static string Get(string url, ref CookieCollection cookie, Encoding encoding, Dictionary<string, string> headers = null, string contentType = HttpContentTypes.ApplicationXWwwFormUrlEncoded, bool autoRedirect = false, bool keepAlive = true, string userAgent = UserAgents.Mozilla4)
         {
             string html = "";
             Stream stream = null;
@@ -31,7 +31,7 @@ namespace Azylee.YeahWeb.HttpUtils.MethodUtils.GetUtils
                 response.Cookies = request.CookieContainer.GetCookies(request.RequestUri);
                 cookie = response.Cookies;
                 stream = response.GetResponseStream();
-                reader = new StreamReader(stream, Encoding.Default);
+                reader = new StreamReader(stream, encoding == null ? Encoding.Default : encoding);
                 html = reader.ReadToEnd();
             }
             catch

+ 2 - 40
Azylee.Utils/Tests/Test.YeahWeb/Program.cs

@@ -14,48 +14,10 @@ namespace Test.YeahWeb
     {
         static void Main(string[] args)
         {
-            //Log log = new Log(true,LogLevel.All,LogLevel.All);
+            var result = IPCNTool.Get();
 
-            string s = "org_plu_share[0-500]";
-            List<string> list = StringGenerator.CreateByNumberSection(s);
-            foreach (var item in list)
-            {
-                Console.Write(item);
-                Console.Write("\t");
-            }
+            var rs2 = IPLocationTool.GetLocation();
 
-
-            // var s = IPLocationTool.GetLocation();
-            //var st =  PublicIPAddressTool.GetPublicIP();
-            // var sss = IPCNTool.Get();
-            // if (s != null)
-            // {
-
-            // }
-
-
-
-
-
-            //var rs = DwzTool.Create("", "http://www.baidu.com");
-            //Console.WriteLine(Json.Object2String(rs));
-
-
-            //PictureScener.GetInfo(1107006764,(int)TimeStampTool.Get(), "",);
-
-            //if (GPSConverter.DeviceGPSToBaiduGPS("", 120.379235583333, 36.19172925, out double x, out double y))
-            //{
-            //    Console.WriteLine($"120.379235583333 - 36.19172925");
-            //    Console.WriteLine($"{x} - {y}");
-            //}
-
-
-            //GPSInfoWebModel model = GPSInfoTool.GetInfo("", 40.039669, 252.129464);
-            //if (model != null)
-            //{
-            //    GPSInfoModel info = model.ToGPSInfoModel();
-            //    Console.WriteLine(info);
-            //}
             Console.ReadLine();
         }
     }