gpt4 book ai didi

c# - 使用 C# 模拟登录到 VBulletin 的操作

转载 作者:行者123 更新时间:2023-11-30 13:05:52 24 4
gpt4 key购买 nike

我正在尝试编写一个程序 (C#),它可以登录并在 VBulletin 论坛中创建新线程。我尝试了两种方式:

1) 使用 HttpWebRequest :登录完成。但是创建新线程失败。这是发布代码:

public static void CreateNewThread(string url,string fId, string title, string message, string tag)
{
url += "newthread.php?do=postthread";

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
//string result = "";

string values = "subject=" + title
+ "&message=" + message
+ "&tag=" + tag
+ "&do=postthread"
+ "&f=" + fId
+ "&s="
+ ""
;

req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = values.Length;

ServicePointManager.Expect100Continue = false; // prevents 417 error

using (StreamWriter writer = new StreamWriter(req.GetRequestStream(), Encoding.UTF8))
{
writer.Write(values);
}

HttpWebResponse c = (HttpWebResponse)req.GetResponse();
}

当a执行上面的代码时,没有创建任何theard!

2)使用WebBrowser控件:

 webBrowser1.Document.GetElementById("navbar_username").InnerText = "admin";
webBrowser1.Document.GetElementById("navbar_password").InnerText = "123";

但我不能提交,因为没有名称/ID,登录按钮是一样的!请告诉我如何提交没有表单名称/ID 和按钮名称/ID 的表单?

谢谢!

此致

最佳答案

尝试模拟发布数据而不是填写表单:

string postData = "username=Kurresmack&password=pw&action=login&url=/";
webBrowser1.Navigate("www.sweclockers.com/forum/member.php", "", System.Text.Encoding.UTF8.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded\r\n");

关于c# - 使用 C# 模拟登录到 VBulletin 的操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2453844/

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