HtmlDocument doc = webBrowser1.Document;
I can only get the Html document if I browse to a page.
Is it possible to get Html document:
- without navigating the webpage?
- Without Using Html Agility Pack?
HtmlDocument doc = webBrowser1.Document;
I can only get the Html document if I browse to a page.
Is it possible to get Html document:
This is one way of doing that
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
WebResponse response = request.GetResponse();
WebBrowser wb = new WebBrowser();
wb.DocumentStream = response.GetResponseStream();
wb.ScriptErrorsSuppressed = true;
HtmlDocument doc = wb.Document;
Same as the WebBrowser control it takes a few seconds for the contents of the stream to populate the control. Also make sure to do proper disposing after you are done.