public string GetIP()
    {
        string strUrl = "http://www.ip138.com/ip2city.asp"; //获得IP的网址了   
        Uri uri = new Uri(strUrl);
        WebRequest wr = WebRequest.Create(uri);
        Stream s = wr.GetResponse().GetResponseStream();
        StreamReader sr = new StreamReader(s, Encoding.Default);
        string all = sr.ReadToEnd(); //读取网站的数据   
        int i = all.IndexOf("[") + 1;

int j = all.IndexOf("]");

          string ip = all.Substring(i, j-i).Trim();

return ip;
    }

相关文章:

  • 2022-12-23
  • 2021-09-03
  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2021-09-20
  • 2021-06-10
  • 2021-05-19
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
相关资源
相似解决方案