gpt4 book ai didi

c# - 为什么要挂这个?

转载 作者:太空狗 更新时间:2023-10-29 23:46:21 24 4
gpt4 key购买 nike

private async void button1_Click(object sender, EventArgs e)
{
var cookie = webBrowser1.Document.Cookie;
await
Task.WhenAll(
listBox1
.Items
.Cast<string>()
.Select(async s =>
{
var data = "action=relationship&user_id=" + s + "&relation=follow";
var req = WebRequest.Create("http://example.com") as HttpWebRequest;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = data.Length;
req.Headers["cookie"] = cookie;
using (var sw = new StreamWriter(await req.GetRequestStreamAsync(), Encoding.ASCII))
{
sw.Write(data);
sw.Close();
}
}));
listBox1.Items.Clear();
}

我已经尝试过一百万次,每次都运行两次。当它运行那两次时,它会做它应该做的事情。

它应该做的是从列表框中取出项目,并将每个项目用作 POST 请求的一部分。完成后,它会清除列表框。

谁能解释一下哪里出了问题?

最佳答案

您应该调用 req.GetResponseAsync() 来实际发送请求。

关于c# - 为什么要挂这个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18393512/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com