0
我正在嘗試自動化.net中的webbrowser。它從網頁中提取數據。以下是已完成活動中的代碼:.net Web瀏覽器刮取器數據未進入Web完成事件
private void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
string url = e.Url.ToString();
if (!(url.StartsWith("http://") || url.StartsWith("https://")))
{
// in AJAX
}
if (e.Url.AbsolutePath != this.wb.Url.AbsolutePath)
{
// IFRAME
}
else
{
// REAL DOCUMENT COMPLETE
txtLogger.Text += "Loaded";
txtLogger.Text += Environment.NewLine;
if (url.Contains("VendorRequisitionDetail"))
{
HtmlElement elem = wb.Document.GetElementById("ctl00_contplhDynamic_VenReqDetSubmission_Reqdiv");
lstData.Add(elem.InnerText);
elem = wb.Document.GetElementById("ctl00_contplhDynamic_VenReqDetSubmission_lblSubMaxSub");
lstData.Add(elem.InnerText);
dt.Rows.Add(lstData[0], lstData[1], string.Empty);
if (frmData != null)
{
frmData.Refresh();
}
counter++;
lstData.Clear();
wb.GoBack();
}
else if (url.Contains("Requisition/List"))
{
if (count > 0)
{
if (counter < count)
{
he = wb.Document.GetElementById("RequisitionGrid");
if (he == null) return;
requisitionIdCollection = he.GetElementsByTagName("tr");
hlink = requisitionIdCollection[counter].Children[13].GetElementsByTagName("a")[1];
hlink.InvokeMember("click");
}
else if (counter == count)
{
IsScraped = true;
txtLogger.Text += "Scraped";
txtLogger.Text += Environment.NewLine;
count = 0;
counter = 0;
}
}
}
}
}
問題是我沒有收到數據。網頁加載並完成事件觸發。但是網頁在某些時候使用某種類型的AJAX加載數據。網站做的是加載頁面並首先顯示加載消息。網頁瀏覽器完成的事件觸發和加載消息,我可以提取。現在網站加載一些數據。我無法完成此次數據加載的完成事件。 如何獲取加載的數據?對不起英語不好。提前致謝。