c# 快速验证代理IP是否有用
2013-09-13 21:23
561 查看
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# 快速验证代理IP是否有用
- c# 快速验证代理IP是否有用
- c# 快速验证代理IP是否有用
- C# 使用HttpWebRequest,HttpWebResponse 快速验证代理IP是否有用
- c# 快速验证代理IP是否有用
- c#使用HttpWebRequest,HttpWebResponse快速验证代理IP是否有用
- c# 使用HttpWebRequest,HttpWebResponse 快速验证代理IP是否有用
- c# 使用HttpWebRequest,HttpWebResponse 快速验证代理IP是否有用
- C# 验证过滤代理IP是否有效
- 【原创】验证代理IP是否有用
- python 爬取西刺免费代理ip 并使用telnetlib.Telnet验证是否有效
- 抓取西刺代理IP+验证是否可用+存储mongodb
- c#编写检测代理IP是否可用
- 使用python验证代理IP是否可用
- 二.验证伪装的代理ip是否成功
- C# 验证IP是否正确简易方法 源代码
- 判断使用的代理IP是否有用
- C# 验证代理IP的方法
- 关于网站是否会封代理IP的验证
- 从西刺代理爬取代理ip,并验证是否可用