首页 »DotNet » httpwebresponse:c# 使用HttpWebRequest HttpWebResponse 快速验证代理IP是否有用 »正文
httpwebresponse:c# 使用HttpWebRequest HttpWebResponse 快速验证代理IP是否有用
来源: 发布时间:星期三, 2009年9月2日 浏览:160次 评论:0
大家好 ![](/icons/90084dou.gif) 相信大家都使用过代理IP上过网 ![](/icons/90084dou.gif) 但是有 ![](/icons/90084de.gif) IP ![](/icons/90084yi.gif) 两天就失效了 ![](/icons/90084dou2.gif) 要 ![](/icons/90084yi.gif) 个 ![](/icons/90084yi.gif) 个 ![](/icons/90084de.gif) 手工去试打开IE ![](/icons/90084dou.gif) 关闭IE ![](/icons/90084dou.gif) 多烦啊 ![](/icons/90084dou2.gif) 有了这篇文章就好了 ![](/icons/90084dou2.gif) 我们可以使用HttpWebRequest,HttpWebResponse 来代理验证 ![](/icons/90084dou.gif) 谢谢大家评论指导! 呵呵 ![](/icons/90084dou.gif) 是不是很简单啊 ![](/icons/90084dou.gif) 其实这段代码改 ![](/icons/90084yi.gif) 下还可以做采集器 ![](/icons/90084dou.gif) 小偷等 ![](/icons/90084chengxu.gif) !我不说了大家自己看 public void yanzhen( str, port) { WebProxy proxyObject = WebProxy(str, port);//str为IP地址 port为端口号 HttpWebRequest Req = (HttpWebRequest)WebRequest.Create("http://www.whatismyip.com.tw/"); Req.Proxy = proxyObject; //设置代理 //转载请标明来自 问题解决园http://wenti.cnblogs.com/ //文章地址 HttpWebResponse Resp = (HttpWebResponse)Req.GetResponse ; str = ""; OkStr = ""; Encoding code = Encoding.GetEncoding("UTF-8"); using (StreamReader sr = StreamReader(Resp.GetResponseStream , code)) { (sr != null) { try { str = sr.ReadToEnd ; StringSub.substr(str, "<h2>", "</h2>", 0); str = str.Sub (str.IndexOf(start) + start.Length); OkStr = str.Sub (0, str.IndexOf(last)); MessageBox.Show("验证成功!显示IP为" + OkStr); } catch { MessageBox.Show("文件读取失败!"); } finally { sr.Close ; } } } } 呵呵 ![](/icons/90084dou.gif) 是不是很简单啊 ![](/icons/90084dou.gif) 其实这段代码改 ![](/icons/90084yi.gif) 下还可以做采集器 ![](/icons/90084dou.gif) 小偷等 ![](/icons/90084chengxu.gif) ! 出处:http://www.cnblogs.com/wenti/archive/2009/07/22/wenti_3.html
相关文章
读者评论
发表评论
|
|