webclient如何使用http代理来访问网页?

by_封爱 版主 2015-10-16 02:54:36
先说下需求..差不多就是不同的IP刷网页吧..

简单代码如下.




private void button1_Click(object sender, EventArgs e)
{
var client = new WebClient();
client.Encoding = Encoding.UTF8;
client.Proxy = CreateProxy();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
client.DownloadStringAsync(new Uri(textBox1.Text)); ;
}
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
Console.WriteLine(e.Result);
}
WebProxy CreateProxy()
{
var proxy = new WebProxy();
var cre = new NetworkCredential();
proxy.Credentials = cre;
return proxy;
}



但是我看网上是这样..



WebProxy proxy = new WebProxy(); //定义代理服务器对象
proxy.Address = new Uri("http://172.25.128.1:80/"); //代理服务器端口
proxy.Credentials = new NetworkCredential("lj669888", "123456");


实际呢 我在网上搜索免费的HTTP代理 没有用户名密码之类的啊...

只有 IP,PORT,匿名度,类型,get/post支持,位置,响应速度,最后验证时间

101.71.27.120
80
高匿名
HTTP
GET, POST
浙江省杭州市 联通


这要怎么写啊. ...


代理地址
...全文
743 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Poopaye 2015-10-16
  • 打赏
  • 举报
回复
proxy.UseDefaultCredentials = true
  • 打赏
  • 举报
回复
就是只要设置proxy的address,后面的响应速度,验证时间都没必要关心的
  • 打赏
  • 举报
回复
如果没账号密码的话,那就是不需要验证,设定false不行吗?
WebProxy proxy = new WebProxy();
proxy.UseDefaultCredentials = false;
vector vecList; vecList.push_back(_T("110.77.0.3:80 ")); vecList.push_back(_T("106.60.94.127:80 ")); vecList.push_back(_T("49.94.32.45:80 ")); vecList.push_back(_T("119.188.94.145:80 ")); vecList.push_back(_T("37.49.137.243:80 ")); vecList.push_back(_T("111.13.132.92:80 ")); vecList.push_back(_T("49.94.148.119:80 ")); vecList.push_back(_T("49.94.164.209:80 ")); vecList.push_back(_T("49.94.2.84:80 ")); vecList.push_back(_T("49.90.1.251:80 ")); vecList.push_back(_T("117.37.243.194:80 ")); vecList.push_back(_T("110.4.12.175:80 ")); vecList.push_back(_T("36.98.30.234:80 ")); vecList.push_back(_T("110.244.111.56:80 ")); vecList.push_back(_T("49.94.131.174:80 ")); vecList.push_back(_T("111.1.61.23:80 ")); vecList.push_back(_T("54.252.97.45:80 ")); vecList.push_back(_T("111.13.12.202:80 ")); vecList.push_back(_T("106.33.2.219:80 ")); vecList.push_back(_T("110.176.86.5:80 ")); vecList.push_back(_T("171.9.147.106:80 ")); vecList.push_back(_T("200.33.27.33:80 ")); vecList.push_back(_T("49.94.141.104:80 ")); vecList.push_back(_T("110.176.178.131:80 ")); vecList.push_back(_T("49.93.24.73:80 ")); vecList.push_back(_T("111.12.128.166:80 ")); vecList.push_back(_T("223.15.233.54:80 ")); vecList.push_back(_T("123.173.206.192:80 ")); vecList.push_back(_T("110.77.197.132:80 ")); vecList.push_back(_T("49.94.0.196:80 ")); WebClient wc; WebClient wc2; CString strData=_T(""); for(int i=0;ihttp://www.2345.com/?24384-1217"),strTemp); str1.Format(_T("%s ->%s\r\n"),strIP,strTemp); strData+=str1; wc2.SetProxy(strIP); wc.Get(_T("http://www.haosooo.cn/?f=me"),strTemp); str1.Format(_T("%s ->%s\r\n"),strIP,strTemp); CSuperLog::WriteLog(str1); Sleep((1000)); } catch (...) { } }

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧