标签:
private static string GetIP() { string tempip = ""; try { WebRequest wr = WebRequest.Create("http://ip.myhostadmin.net/"); Stream s = wr.GetResponse().GetResponseStream(); StreamReader sr = new StreamReader(s, Encoding.Default); string all = sr.ReadToEnd(); //读取网站的数据 all = all.Replace("class=\"STYLE1\">", "*"); all = all.Replace("</h1>", "&"); int start = all.IndexOf("*") + 1; int end = all.LastIndexOf("&"); tempip = all.Substring(start, end - start); sr.Close(); s.Close(); } catch { } return tempip; }
标签:
原文地址:http://www.cnblogs.com/hz1234/p/5939026.html