How to get the HTML source from the WebBrowser Control
-
Hi everyone. In my application, I use WebBrowser control to send HTTP request and get HTTP response. The response result is the HTML source(am i right?) which can be viewed by clicking View Source in the popup menu. The problem is that the response is not the HTML code , but application-defined data. and I find that the following code works when the response is HTML code,but fails when my application-defined data: IHTMLDocument2 * pDoc = (IHTMLDocument2 *)(m_ie.GetDocument()); BSTR str; IHTMLElement * pElement = NULL; pDoc->get_body(&pElement); pElement->get_outerText(&str); //get_innerText Because sometimes my application data is XML-like format , get_outerText(or inner) will remove the XML tags, that's not what I expect. get_outerHTML(or inner) will add some tags in my application data because there are tags in it. I just want to implement a function that just like "View Source" menu item to get the full actual HTTP response.I use WebBrowser control because it can manage session automatically. Thanks.
-
Hi everyone. In my application, I use WebBrowser control to send HTTP request and get HTTP response. The response result is the HTML source(am i right?) which can be viewed by clicking View Source in the popup menu. The problem is that the response is not the HTML code , but application-defined data. and I find that the following code works when the response is HTML code,but fails when my application-defined data: IHTMLDocument2 * pDoc = (IHTMLDocument2 *)(m_ie.GetDocument()); BSTR str; IHTMLElement * pElement = NULL; pDoc->get_body(&pElement); pElement->get_outerText(&str); //get_innerText Because sometimes my application data is XML-like format , get_outerText(or inner) will remove the XML tags, that's not what I expect. get_outerHTML(or inner) will add some tags in my application data because there are tags in it. I just want to implement a function that just like "View Source" menu item to get the full actual HTTP response.I use WebBrowser control because it can manage session automatically. Thanks.