Uri uri = new Uri("http://www.ip138.com/ip2city.asp"); System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; req.Referer = "http://www.ip138.com/ip2city.asp"; req.ContentLength = 0; req.CookieContainer = new System.Net.CookieContainer(); req.GetRequestStream().Write(new byte[0], 0, 0); System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)(req.GetResponse()); StreamReader rs = new StreamReader(res.GetResponseStream(), System.Text.Encoding.GetEncoding("gb2312")); string s = rs.ReadToEnd(); rs.Close(); req.Abort(); res.Close(); System.Text.RegularExpressions.Match m = System.Text.RegularExpressions.Regex.Match(s, @"\[(?<IP>[0-9\.]*)\]");
- 8 回答
- 0 关注
- 555 浏览
添加回答
举报
0/150
提交
取消