Browse Source

百度接口改动,跟随修改(野API果然不靠谱)

yuzhengyang 7 years ago
parent
commit
9f2162f264

+ 9 - 5
Fork.Net/Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/IPLocationAPI/IPLocationTool.cs

@@ -14,11 +14,15 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
         public static IPLocationModel GetLocation()
         {
             IPLocationWebModel model = null;
-            CookieCollection cookie = new CookieCollection();
-            string rss1 = HttpToolPlus.Get(URL, ref cookie);//第一次请求以获取Cookie
-            string rss2 = HttpToolPlus.Get(URL, ref cookie);//携带第一次的Cookie获取数据
-            model = JsonConvert.DeserializeObject<IPLocationWebModel>(rss2);
-            return model.ToIPLocationModel();
+            try
+            {
+                CookieCollection cookie = new CookieCollection();
+                string rss1 = HttpToolPlus.Get(URL, ref cookie);//第一次请求以获取Cookie
+                string rss2 = HttpToolPlus.Get(URL, ref cookie);//携带第一次的Cookie获取数据
+                model = JsonConvert.DeserializeObject<IPLocationWebModel>(rss2);
+                return model.ToIPLocationModel();
+            }
+            catch (Exception e) { return null; }
         }
     }
 }

+ 22 - 6
Fork.Net/Azylee.Utils/Azylee.YeahWeb/BaiDuWebAPI/IPLocationAPI/IPLocationWebModel.cs

@@ -6,7 +6,7 @@ using System.Text;
 
 namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
 {
-    public class IPLocationWebModel
+    class IPLocationWebModel
     {
         /// <summary>
         /// 
@@ -104,7 +104,7 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
             /// <summary>
             /// 
             /// </summary>
-            public int confidence { get; set; }
+            public double confidence { get; set; }
             /// <summary>
             /// 
             /// </summary>
@@ -199,7 +199,7 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
             /// <summary>
             /// 
             /// </summary>
-            public List<string> poiRegions { get; set; }
+            public List<PoiRegionsItem> poiRegions { get; set; }
             /// <summary>
             /// 中车青岛四方机车车辆股份有限公司西北296米
             /// </summary>
@@ -279,7 +279,6 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
             /// </summary>
             public string distance { get; set; }
         }
-
         public class Point
         {
             /// <summary>
@@ -291,7 +290,6 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
             /// </summary>
             public double y { get; set; }
         }
-
         public class Parent_poi
         {
             /// <summary>
@@ -323,7 +321,6 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
             /// </summary>
             public string uid { get; set; }
         }
-
         public class PoisItem
         {
             /// <summary>
@@ -375,5 +372,24 @@ namespace Azylee.YeahWeb.BaiDuWebAPI.IPLocationAPI
             /// </summary>
             public Parent_poi parent_poi { get; set; }
         }
+        public class PoiRegionsItem
+        {
+            /// <summary>
+            /// 内
+            /// </summary>
+            public string direction_desc { get; set; }
+            /// <summary>
+            /// 中车青岛四方机车车辆股份有限公司
+            /// </summary>
+            public string name { get; set; }
+            /// <summary>
+            /// 公司企业;公司
+            /// </summary>
+            public string tag { get; set; }
+            /// <summary>
+            /// 
+            /// </summary>
+            public string uid { get; set; }
+        }
     }
 }