根据网上源码综合的使用代理的投票程序,几个问题解决不了,讨论下

oneby 2007-06-18 12:20:34
程序可以运行,也可以投票。问题:在网上找的代理ip大多报错,不知是ip不能用,还是代码的问题?投票的速度很慢,不知怎么解决?欢迎讨论,争取今天解决
...全文
194 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
oneby 2007-06-18
  • 打赏
  • 举报
回复
Stream newStream=hwr.GetRequestStream();
// Send the data.
newStream.Write(temp,0,temp.Length);
newStream.Close();
HttpWebResponse myResponse=(HttpWebResponse)hwr.GetResponse();
StreamReader reader = new StreamReader(myResponse.GetResponseStream(),Encoding.Default);
string content = reader.ReadToEnd();

if(content.IndexOf("不接受重复投票")< 0)
{
count ++;
}
}
catch(Exception ex)
{
}
}
oneby 2007-06-18
  • 打赏
  • 举报
回复
private void poll(string p)
{
try
{
byte[]temp = Encoding.ASCII.GetBytes("此处是提交的数据");
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create("此处是数据提交的地址");
hwr.Method = "POST";
hwr.ContentType="application/x-www-form-urlencoded";
hwr.ContentLength = temp.Length;
WebProxy wp = new WebProxy(p,true);
hwr.Proxy = wp;
oneby 2007-06-18
  • 打赏
  • 举报
回复
private void button1_Click(object sender, System.EventArgs e)
{
try
{//代理服务的ip和端口放在poll.txt文件中
StreamReader s = File.OpenText("poll.txt");
string read = null;
while((read = s.ReadLine()) != null)
{
poll(read);//读取每一行代理ip的数据,开始投票
}
s.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message,"Error");
}


}

110,535

社区成员

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

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

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