string location = "0";//0是网通 1是电信
Uri uri = new Uri("http://www.ip138.com/ips138.asp");
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);
req.Method = "get";
using (System.IO.Stream s = req.GetResponse().GetResponseStream())
{
using (System.IO.StreamReader reader = new System.IO.StreamReader(s,Encoding.GetEncoding("gb2312")))
{
string str = reader.ReadToEnd();
if (str.Contains("电信"))
{
location = "1";
}
}
}
转载于:https://www.cnblogs.com/AlienXu/p/6875980.html