I’m trying to use WebBrowser class, but of course it doesn’t work.
My code:
WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
while(browser.DocumentText == "")
{
continue;
}
string html = browser.DocumentText;
browser.DocumentText is always "". Why?
The WebBrowser isn’t going to do it’s job until the current thread finishes it’s work, if you changed it to be something like this:
The variable will be set.
But, as others have mentioned, the document completed is a better event to attach to, as at that time, the entire document will be completed (appropriate name!)