懒得勤快 8 years ago
parent
commit
4fb3137f6d
2 changed files with 13 additions and 0 deletions
  1. 10 0
      Masuit.Tools/Net/WebExtension.cs
  2. 3 0
      Test/Program.cs

+ 10 - 0
Masuit.Tools/Net/WebExtension.cs

@@ -337,6 +337,16 @@ namespace Masuit.Tools.Net
                         return address;
                     }
                 }
+                else
+                {
+                    client = new HttpClient {BaseAddress = new Uri("http://ip.taobao.com")};
+                    var result = client.GetStringAsync($"/service/getIpInfo.php?ip={ip}").Result;
+                    TaobaoIP taobaoIp = JsonConvert.DeserializeObject<TaobaoIP>(result);
+                    if (taobaoIp.Code == 0)
+                    {
+                        return new PhysicsAddress() { Status = 0, AddressResult = new AddressResult() { FormattedAddress = taobaoIp.IpData.Country, AddressComponent = new AddressComponent() { Province = taobaoIp.IpData.Region } } };
+                    }
+                }
             }
             return null;
         }

+ 3 - 0
Test/Program.cs

@@ -1,4 +1,6 @@
 using System;
+using Masuit.Tools.Models;
+using Masuit.Tools.Net;
 
 namespace Test
 {
@@ -42,6 +44,7 @@ namespace Test
             //Console.WriteLine(WindowsCommand.Execute("help"));
             //string match = "vawevbgw".MatchRandomImgSrc();
             //Console.WriteLine(match);
+            PhysicsAddress address = "4.2.2.1".GetPhysicsAddressInfo();
 
             Console.ReadKey();
         }