• c# 快速验证代理IP是否有用


     public void yanzhen(string str, int port)
            {
                WebProxy proxyObject = new WebProxy(str, port);//str为IP地址 port为端口号
                HttpWebRequest Req = (HttpWebRequest)WebRequest.Create("http://www.whatismyip.com.tw/");
                Req.Proxy = proxyObject; //设置代理
                HttpWebResponse Resp = (HttpWebResponse)Req.GetResponse();
                string str = "";
                string OkStr = "";
                Encoding code = Encoding.GetEncoding("UTF-8");
                using (StreamReader sr = new StreamReader(Resp.GetResponseStream(), code))
                {
                    if (sr != null)
                    {
                        try
                        {
                            str = sr.ReadToEnd();
                            StringSub.substr(str, "<h2>", "</h2>", 0);
                            str = str.Substring(str.IndexOf(start) + start.Length);
                            OkStr = str.Substring(0, str.IndexOf(last));
                            MessageBox.Show("验证成功!显示IP为" + OkStr);
                        }
                        catch
                        {
                            MessageBox.Show("文件读取失败!");
                        }
                        finally
                        {
                            sr.Close();
                        }
                    }
                }
            }

  • 相关阅读:
    MySQL-安装mysql8
    MySQL-Prometheus
    MySQL-sysbench
    MySQL-客户端登录问题
    学习进度第十六周
    学习进度第十五周
    寻找最长单词链
    用户体验评价
    学习进度第十四周
    找水王问题
  • 原文地址:https://www.cnblogs.com/zcm123/p/4236470.html
Copyright © 2020-2023  润新知