void GetHtmlContent()
{
//m_Explorer
HRESULT hr;
LPDISPATCH pDisp;
IHTMLDocument2* phd;//IHtmlDocument2接口指針
IHTMLElement* pBody;//網頁中的元素
pDisp = m_Explorer.get_Document();
hr = pDisp->QueryInterface(IID_IHTMLDocument2, (LPVOID*)&phd);
pDisp->Release();
if (SUCCEEDED(hr))
{
BSTR bstrText;
hr = phd->get_body(&pBody); //BODY
if (SUCCEEDED(hr))
{
hr = pBody->get_innerText(&bstrText);
if (SUCCEEDED(hr))
{
//PrintBSTR(bstrText); // 處理得到的文本
char* lpszText2 = _com_util::ConvertBSTRToString(bstrText);
g_Log.print(LogLevel_Info,"[info] GetHtmlContent:%s.\n",lpszText2);
SysFreeString(bstrText);
//AfxMessageBox("擷取成功");
}
}
SysFreeString(bstrText);
}
phd->Release();
pBody->Release();
}
原文:http://blog.csdn.net/loveheronly/article/details/38172487