c# 快速验证代理IP是否有用
2015-01-20 16:34
471 查看
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();
}
}
}
}
{
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();
}
}
}
}
相关文章推荐
- C# 使用HttpWebRequest,HttpWebResponse 快速验证代理IP是否有用
- c# 快速验证代理IP是否有用
- c# 快速验证代理IP是否有用
- c# 使用HttpWebRequest,HttpWebResponse 快速验证代理IP是否有用
- c#使用HttpWebRequest,HttpWebResponse快速验证代理IP是否有用
- c# 快速验证代理IP是否有用
- c# 使用HttpWebRequest,HttpWebResponse 快速验证代理IP是否有用
- c# 快速验证代理IP是否有用
- C# 验证过滤代理IP是否有效
- 【原创】验证代理IP是否有用
- #如何用ping的方法验证代理IP是否可用
- python验证IP代理是否可用
- 使用python验证代理ip是否可用的实现方法
- 怎样快速判断代理ip是否可用
- python 爬取西刺免费代理ip 并使用telnetlib.Telnet验证是否有效
- 抓取西刺代理IP+验证是否可用+存储mongodb
- 使用python验证代理IP是否可用
- 关于网站是否会封代理IP的验证
- C# 验证IP是否正确简易方法 源代码
- C# 验证代理IP的方法