我的使用 HttpWebRequest 的自动论坛线程生成器有什么问题?

发布于 2024-09-18 15:06:18 字数 676 浏览 7 评论 0原文

我正在使用 HttpWebRequest 发送请求,而不使用浏览器,但我总是从这个老派的 cgi 论坛得到这个回复:“重复线程”。我很确定该线程不是重复的,因为这是我第一次发送它。我猜测论坛软件正在检测我的线程的异常情况,因为它是机器生成的。我能做些什么?

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://pop.6park.com/cgi-bin/know1/mainboard.pl");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
string postData = "name=ZhuangNan&usrpwd=aaa&subject=whatisthis&body=abcabcabcabc";
UTF8Encoding encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(postData);
myRequest.ContentLength = byte1.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);

I'm using HttpWebRequest to send request without using a browser but I always get this reply from this old school cgi forum: "duplicate thread". I'm pretty sure the thread is not a duplicate as it is the first time I send it. I'm guessing the forum software is detecting something unusual about my thread as is is machine generated. What can I do?

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://pop.6park.com/cgi-bin/know1/mainboard.pl");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
string postData = "name=ZhuangNan&usrpwd=aaa&subject=whatisthis&body=abcabcabcabc";
UTF8Encoding encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(postData);
myRequest.ContentLength = byte1.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

靑春怀旧 2024-09-25 15:06:18

如果目标脚本尝试检查 UserAgent HTTP 标头以确定请求是否由浏览器发出,您可以尝试填充 HttpWebRequest.UserAgent 属性 具有有效值。这至少有一次对我有用。

您可以设置许多其他 HTTP 标头,以使目标脚本认为它是由浏览器而不是程序访问的。

查看可以设置的任何 HTTP 标头属性。请参阅 HttpWebRequest 属性了解更多信息。

If the target script tries to check the UserAgent HTTP header to determine if the request is being made by a browser, you can try populating the HttpWebRequest.UserAgent property with a valid value. This has worked for me on at least one occasion.

There are a number of other HTTP headers that you could set to make the target script think it is being hit by a browser rather than a program.

Check out any of the HTTP header properties that can be set. See HttpWebRequest Properties for more information.

爱她像谁 2024-09-25 15:06:18
myRequest.ContentType = "application/x-www-form-urlencoded";
string postData = "name=ZhuangNan&usrpwd=aaa&subject=whatisthis&body=abcabcabcabc";

不是 MIME/baseenc 数据?

myRequest.ContentType = "application/x-www-form-urlencoded";
string postData = "name=ZhuangNan&usrpwd=aaa&subject=whatisthis&body=abcabcabcabc";

Not a MIME/baseenc data?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文