有框架的网页,如何读取框架里的源码

2024-12-29 08:49:32
推荐回答(2个)
回答1:

用chtmlview打带框架网页写面函数
BOOL CHtmlView::GetFrameSource( IDispatch *pDisp, CString& refString )
{
BOOL bRetVal = FALSE;
HRESULT hr = S_OK;
if ( pDisp != NULL )
{
CComQIPtr pBrowser = pDisp;
if ( pBrowser != NULL )
{
IDispatch *pDispDoc = NULL;
hr = pBrowser->get_Document(&pDispDoc);
if ( !( FAILED(hr) || !pDisp ) )
{
CComQIPtr pStmInit = pDisp;
if ( !pStmInit )
{
HGLOBAL hMemory;
hMemory = GlobalAlloc(GMEM_MOVEABLE, 0);
if (hMemory != NULL)
{
CComQIPtr spPSI = pDispDoc;
if( spPSI != NULL)
{
CComPtr spStream;
if (SUCCEEDED(CreateStreamOnHGlobal(hMemory, TRUE, &spStream)))
{
spPSI->Save(spStream, FALSE);
LPCTSTR pstr = (LPCTSTR) GlobalLock(hMemory);
if (pstr != NULL)
{
// Stream is always ANSI, but CString
// assignment operator will convert implicitly.
bRetVal = TRUE;
TRY
{
refString = pstr;
}
CATCH_ALL(e)
{
bRetVal = FALSE;
DELETE_EXCEPTION(e);
}
END_CATCH_ALL

if(bRetVal == FALSE)
GlobalFree(hMemory);
else
GlobalUnlock(hMemory);
}
}
}
}
}
}
RELEASE(pDispDoc);
}
}
return bRetVal;
}

能用DocumentComplete我知道获pDisp像DocumentComplete才能获框架各页pDisp没通用性我想要实现像GetSource功能要网页载完毕任意刻获框架html源文件!

回答2:

查看网页源代码
找到。。。


src="do.asp"(表示在相同路径下)