zoukankan      html  css  js  c++  java
  • 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();
                        }
                    }
                }
            }

  • 相关阅读:
    Nginx负载均衡配置实例详解
    网络性能排查
    tensorflow、cuda、cudnn之间的版本对应关系
    PyPI可以使用的几个国内源
    Ceres配置(vs2013+Win10)
    vs2013+opencv3.2配置
    Ceres Solver 在win8+vs2013环境下的安装
    51Nod-1006 最长公共子序列Lcs
    Qt中OpenGL模块下将图片转化为纹理,并传入shader中
    harris角点检测
  • 原文地址:https://www.cnblogs.com/zcm123/p/4236470.html
Copyright © 2011-2022 走看看