string StoreName = IpLocation("222.77.181.13");
public string IpLocation(string ipAddress)
{
string[] result;
if (string.IsNullOrEmpty(ipAddress.Trim()))
{
return null;
}
WebClient client = new WebClient();
client.Encoding = System.Text.Encoding.GetEncoding("GB2312");
string url = "
http://www.ip138.com/ips.asp";
string post = "ip=" + ipAddress + "&action=2";
client.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
string response = client.UploadString(url, post);
string p = @"<li>参考数据一:(?<location>[^<>]+?)</li>";
Match match = Regex.Match(response, p);
string m_Location = match.Groups["location"].Value.Trim();
result = m_Location.Split(' ');
return result[0];
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。