我的使用 HttpWebRequest 的自动论坛线程生成器有什么问题?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果目标脚本尝试检查 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.
不是 MIME/baseenc 数据?
Not a MIME/baseenc data?