我试过:
var browser1 = new WebBrowser();
browser1.Navigate("https://zikiti.co.il/");
HtmlDocument document = browser1.Document;
但是 browser.Document
为空。
为什么?
我做错了什么?
public static void FillForm()
{
browser1 = new WebBrowser();
browser1.Navigate(new Uri("https://zikiti.co.il/"));
browser1.Navigated += webBrowser1_Navigated;
Thread.CurrentThread.Join();
}
private static void webBrowser1_Navigated(object sender,
WebBrowserNavigatedEventArgs e)
{
HtmlDocument document = browser1.Document;
System.Console.WriteLine();
}
应用程序卡住了。 顺便说一句,有没有更简单的方法来填写和提交此表格? (我在 Fiddler 中看不到请求头,因为页面总是被 JS 阻止)。
最佳答案
因为下载html需要时间。没有人愿意等待的时间量,尤其是用户界面线程,如今沙漏不再适用。
它明确地告诉您它何时可用。 DocumentCompleted 事件。
您必须启动消息循环才能获得该事件。
关于c# - 为什么 WebBrowser.Navigate 返回 null HttpDocument?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7536075/