根据ip获取地点

#region 根据ip获取地点
/// 获取Ip归属地
/// </summary>
/// <param name="ip">ip</param>
/// <returns>归属地</returns>
public static string GetIpAddress(string ip)
{
JavaScriptSerializer Jss = new JavaScriptSerializer();
//http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=218.192.3.42 调用新浪的接口
string address = string.Empty;
try
{
string reText = WebRequestPostOrGet("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=" + ip, "");
Dictionary<string, object> DicText = (Dictionary<string, object>)Jss.DeserializeObject(reText);
address = DicText["city"].ToString();
//Log.Loger("city:" + address, true);
}
catch { }
return address;
}
#endregion

posted @ 2018-07-06 15:44  BIGBOY_GU  阅读(530)  评论(1编辑  收藏  举报