& lt; Div id="div1" name="RE" & gt; Hello, this is the data! & lt;/div>
Ask, how to use VC through Microsoft web browser control, read data from a DIV column above?
Are the requirements for the final result:
Cstrings sStr;
SStr="hello, this is data!"
Please advise,
CodePudding user response:
Using CHtmlView etc, loading the page, and then you can get content by IHtmlDocument etcCodePudding user response:
Due to plan to put this part into a DLL, so no use CHtmlView, but with the Microsoft web browser controls,Seven years ago I had ever written in VB code also take out now how also forget not clear with VC, multi-directions under the tower,
CodePudding user response:
Can be obtained through the handle to the window HWND web page, the IHTMLDocument2 pointer,Then visit the page content by IHTMLDocument2,
Resources:
1, know the HWND of a web page, how to get the text content of the page, or the source code can also, http://www.debugease.com/vb/3188722.html
2, the MSDN article: HOWTO: Get IHTMLDocument2 from a HWND (Q249232)
CodePudding user response:
XML parsing, we can find a XML parsing classCodePudding user response:
bool CPublic: : sGetText (cstrings URL, cstrings & amp; OutText)
{
CInternetSession session;
Try
{
CHttpFile * pF=(CHttpFile *) session. OpenURL (URL, 1, INTERNET_FLAG_TRANSFER_ASCII | INTERNET_FLAG_RELOAD, NULL, 0).
Cstrings strTempData="";
Cstrings strData="";
While (pF - & gt; ReadString (strTempData))
{
StrData +="\ r \ n";
StrData +=strTempData;
}
//AfxMessageBox (strData);//display page source code
OutText=strData;
StrTempData. ReleaseBuffer ();
StrData. ReleaseBuffer ();
PF - & gt; Close ();
The delete pF.
The session. The Close ();//close the session
}
The catch (CInternetException * e)
{
E - & gt; The Delete ();
}
If (OutText. IsEmpty ())
{
return false;
}
The else
{
return true;
}
}
CodePudding user response:
Through the ActiveX classes can WinInet,CodePudding user response:
If only some simple applications, as from the text directly to parsing