Andrew
Andrew

Reputation: 7768

load page into the webBrowser and grab HTML

I need to load the page into the webBrowser, wait for this page to load (including the ajax) and then grab the HTML of that page.

I tried this, but it seems to be not working as intended. Any help would be great!

WebBrowser webBrowser = new WebBrowser();
webBrowser.Navigate("http://www.mysite.com");
String htmldoc = webBrowser.DocumentText;

Upvotes: 1

Views: 438

Answers (1)

animaonline
animaonline

Reputation: 3794

Subscribe to DocumentCompleted...

private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    string htmldoc = webBrowser.Document.Body.InnerHtml;
}

That should do the trick.

Upvotes: 2

Related Questions