我有以下代码,我想知道如何让代码等待WebBrowser在激活提交按钮后加载下一页:
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = false;
wb.ScriptErrorsSuppressed = false;
wb.Navigate(baseUrl+uri);
while (wb.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); }
var docTitle1 = wb.DocumentTitle;
foreach (HtmlElement form in wb.Document.Forms)
form.InvokeMember("submit");
Stream dataStream = wb.DocumentStream;
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);
我可以在激活提交时听到咔嗒声,但是当它已经在代码末尾时我会听到。如果我放置一个中断,我可以看到wb对象具有上一页的数据。
谢谢!