Home > Software engineering >  How can use CWebBrowser2 view to the browser review elements under the function of the source code?
How can use CWebBrowser2 view to the browser review elements under the function of the source code?

Time:11-16

I join IDC_EXPLORER controls in the dialog, and use CWebBrowser2 to open the specified page, want through the web page's source code, such as: http://www.clloo.com/m/snapup/26447671.html, a web page may be jump, in the browser view source directly, don't have any thing, but in the F12 can see a lot of review under the element function, also is I want to see, don't know how to implement,

I simply can not get the desired results, use the following code directly, please!!!!!!
Void CWeb_TestDlg: : OnDocumentCompleteExplorer1 (LPDISPATCH pDisp and VARIANT FAR * URL)
{
//TODO: Add your the control notification handler code here
Cstrings info;
BSTR BSTR.
HRESULT HRESULT=S_OK;
IHTMLElement * pElement1=NULL;
IHTMLElement * pElement2=NULL;

IHTMLDocument2 * pDoc=(IHTMLDocument2 *) m_web GetDocument ();
If (NULL!=pDoc)
{
HResult=pDoc - & gt; Get_body (& amp; PElement1);
If (S_OK==hResult & amp; & NULL!=pElement1)
{
HResult=pElement1 - & gt; Get_parentElement (& amp; PElement2);
If (S_OK==hResult & amp; & NULL!=pElement2)
{
HResult=pElement2 - & gt; Get_outerHTML (& amp; BSTR);
If (S_OK==hResult)
{
PDoc - & gt; Release ();
PDoc=NULL;
PElement1 - & gt; Release ();
PElement1=NULL;
PElement2 - & gt; Release ();
PElement2=NULL;
}
}
}
}
The else
{
If (NULL!=pDoc)
{
PDoc - & gt; Release ();
PDoc=NULL;
}
If (NULL!=pElement1)
{
PElement1 - & gt; Release ();
PElement1=NULL;
}
If (NULL!=pElement2)
{
PElement2 - & gt; Release ();
PElement2=NULL;
}
return;
}
Info=BSTR;
SysFreeString (BSTR);
}

CodePudding user response:

Asked the great spirit

CodePudding user response:

CodePudding user response:

Save as HTML web pages to see, whether to have multiple files? See if there was any clue

CodePudding user response:

Obviously pages with AJAX, so the DocumentComplete page elements has not been created, such as the end of the script to visit again, also can wait for a few seconds with timer,
Like the score immediately suggests that this could have been run script, that's no way out, can brush with timer,

CodePudding user response:

reference 4 floor Jiang Sheng response:
obviously pages with AJAX, so DocumentComplete page elements has not been created, such as the end of the script to visit again, also can wait for a few seconds with timer,
As likely score instantly shows this script has been run, that's no way out, can brush with timer,


This is can't use the DocumentComplete function, what use that function? And how can know the script and then to the end of the time to visit?

CodePudding user response:

If you find the script element, you can go hang HTMLScriptEvents2: : onactivate
Can't find you can at the time of the last DocumentComplete (pDisp is first pDisp BeforeNavigate2 event, if pages are not download the Word documents, HTML this non-html content can also go to check the top documents ready state) start the timer,
  • Related