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();
                        }
                    }
                }
            }

  • 相关阅读:
    JVMTIAgent
    Java 虚拟机编程接口JVMIT
    Java调试平台体系JPDA
    什么是缓存
    2019第49周日
    什么是你拥有的资本
    java里的static/final含义
    Java语言和JVM的使用说明书
    画图前端:mermaid。时序图/类图/甘特图/流程图/状态图/饼图。类似工具:Typora
    java通过下划线数字字面量增加可读性:10_00_00表示100000
  • 原文地址:https://www.cnblogs.com/zcm123/p/4236470.html
Copyright © 2011-2022 走看看