S
Sudip_inn
Guest
This is how i tried. i load a web site into web browser control. the web site load more data when we scroll down.
this web site load data dynamically by ajax. i try to read all dynamic h3 tag loaded by ajax but my code did not work.
here is my code
private void BrowserTest_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(" View: https://www.pinterest.com/pin/517210338432366716/
");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
HtmlElement elm = webBrowser1.Document.GetElementById("h3"); // Get "abc" element by ID
//Console.WriteLine("elm.InnerHtml(DocumentCompleted):" + elm.InnerHtml);
if (elm != null)
{
elm.AttachEventHandler("onpropertychange", new EventHandler(handler));
}
}
}
private void handler(Object sender, EventArgs e)
{
HtmlElement div = webBrowser1.Document.GetElementById("h3");
if (div == null) return;
String contentLoaded = div.InnerHtml;
}
private void btnScrollDown_Click(object sender, EventArgs e)
{
if (webBrowser1.Document != null)
{
webBrowser1.Document.Window.ScrollTo(0, webBrowser1.Document.Body.ScrollRectangle.Height);
}
}
This elm is always getting null. so tell me where i made the mistake? where to change in code ?
thanks
Continue reading...
this web site load data dynamically by ajax. i try to read all dynamic h3 tag loaded by ajax but my code did not work.
here is my code
private void BrowserTest_Load(object sender, EventArgs e)
{
webBrowser1.Navigate(" View: https://www.pinterest.com/pin/517210338432366716/
");
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
HtmlElement elm = webBrowser1.Document.GetElementById("h3"); // Get "abc" element by ID
//Console.WriteLine("elm.InnerHtml(DocumentCompleted):" + elm.InnerHtml);
if (elm != null)
{
elm.AttachEventHandler("onpropertychange", new EventHandler(handler));
}
}
}
private void handler(Object sender, EventArgs e)
{
HtmlElement div = webBrowser1.Document.GetElementById("h3");
if (div == null) return;
String contentLoaded = div.InnerHtml;
}
private void btnScrollDown_Click(object sender, EventArgs e)
{
if (webBrowser1.Document != null)
{
webBrowser1.Document.Window.ScrollTo(0, webBrowser1.Document.Body.ScrollRectangle.Height);
}
}
This elm is always getting null. so tell me where i made the mistake? where to change in code ?
thanks
Continue reading...