/// <summary> /// 根据IP获取其所在地区 /// </summary> /// <param name="str">地区名</param> /// <returns>返回IP,未查询到返回null</returns> public static string GetLocationByIp(this string str) { var ipRead = LocatorFactory.GetLocator(Locator.QQWry); var data = ipRead.Query(str); if (data == null) { return(null); } return(data.Country); }
public void TestMethod2() { var helper = LocatorFactory.GetLocator(Locator.QQWry); helper.Initiation(); var ip = helper.Query("118.122.117.55"); Assert.AreEqual("电信", ip.Local); Assert.AreEqual("四川省成都市", ip.Country); Assert.AreEqual("四川省", ip.Province); Assert.AreEqual("成都市", ip.City); }
public void TestMethod1() { var helper = LocatorFactory.GetLocator(Locator.QQWry); helper.Initiation(); var ip = helper.Query("182.140.147.57"); Assert.AreEqual("上海网宿科技股份有限公司电信CDN节点", ip.Local); Assert.AreEqual("四川省成都市", ip.Country); Assert.AreEqual("四川省", ip.Province); Assert.AreEqual("成都市", ip.City); }
public void TestMethod6() { var helper = LocatorFactory.GetLocator(Locator.QQWry); helper.Initiation(); var ip = helper.Query("1.4.4.255"); //Assert.AreEqual("北龙中网(北京)科技有限责任公司", ip.Local); Assert.AreEqual("北京市海淀区", ip.Country); Assert.AreEqual("北京市", ip.Province); Assert.AreEqual("海淀区", ip.City); }
public void TestMethod4() { //27.98.233.255 西藏拉萨市 联通 var helper = LocatorFactory.GetLocator(Locator.QQWry); helper.Initiation(); var ip = helper.Query("27.98.233.255"); Assert.AreEqual("联通", ip.Local); Assert.AreEqual("西藏拉萨市", ip.Country); Assert.AreEqual("西藏", ip.Province); Assert.AreEqual("拉萨市", ip.City); }
public void TestMethod3() { //1.15.255.255 北京市 北京北大方正宽带网络科技有限公司 var helper = LocatorFactory.GetLocator(Locator.QQWry); helper.Initiation(); var ip = helper.Query("1.15.255.255"); Assert.AreEqual("北京北大方正宽带网络科技有限公司", ip.Local); Assert.AreEqual("北京市", ip.Country); Assert.AreEqual("北京市", ip.Province); Assert.AreEqual("北京市", ip.City); }