Reading HTML from iframe using C # Webbrowser

How to read IFRAME html code using WebBrowser?

I have a site with an iframe, and after a few clicks, a new URL opens inside this IFRAME with some HTML CODE. Is there any way to read this ?. When I try to move () to this URL, I am redirected to the main page of this site (it is not possible to open this link twice).

Uri IFRAME_URL = webBrowser1.Document.Window.Frames[0].Url;

Perhaps something similar to:

Uri IFRAME_URL = webBrowser1.Document.Window.Frames[0].  ... DOCUMENTTEXT;
+5
source share
4 answers

Try:

string content = webBrowser1.Document.Window.Frames[0].WindowFrameElement.InnerText;
+3
source

You can also acquire various elements through mshtml types:

Set the link to the "Microsoft HTML Object Library" in COM links.

Define your using statement:

using mshtml;

API- mshtml, :

HTMLFrameBase frame = yourWebBrowserControl.Document.GetElementById( "yourFrameId" ).DomElement as HTMLFrameBase;

"frame" , , .

+1

:

string content = webBrowser1.Document.Window.Frames [0].Document.Body.InnerText

+1

WebBrowser , iframe .net , - :

// Setup a string variable...
string html = string.Empty;

// webBrowser1.Document.Window.Frames gets a collection of iframes contained in the current document...
// HTMLWindow is the iterator for the Collection...
foreach (HtmlWindow frame in webBrowser1.Document.Window.Frames)
{
html += frame.Document.Body.OuterHtml;
}

, , iframe, .

0

All Articles