110,533
社区成员
发帖
与我相关
我的任务
分享
System.Net.WebClient client = new System.Net.WebClient();
client.Encoding =System.Text.Encoding.Default;
string reply = client.DownloadString( "http://www.ip138.com/ip2city.asp" );
MessageBox.Show( reply );
try
{
string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址了
Uri uri = new Uri(strUrl);
System.Net.WebRequest wr = System.Net.WebRequest.Create(uri);
System.IO.Stream s = wr.GetResponse().GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(s, Encoding.Default);
string all = sr.ReadToEnd(); //读取网站的数据
int i = all.IndexOf("[") + 1;
string tempip = all.Substring(i, 15);
string ip = tempip.Replace("]", "").Replace(" ", "");//找出i
}
catch (Exception ex)
{
}