|
제 답변은 아닙니다. 이전에 참고했던 문서입니다.
You need to first get the IHTMLDocument pointer to the specific frame page,
then you can get it's source.
Try this (untested):
IHTMLDocument2 *HTMLDocument = NULL;
WideString FrameName("myframe");
if(SUCCEEDED(BrowserForm->WebBrowser->Document->QueryInterface(IID_IHTMLDocu
ment2, (LPVOID*)&HTMLDocument)))
{
IHTMLFramesCollection2 *pFrames = NULL;
if(SUCCEEDED(HTMLDocument->get_frames(&pFrames)))
{
VARIANT vFrame;
vFrame.vt = VT_BSTR;
vFrame.bstrVal = FrameName.c_bstr();
VARIANT ret;
if(SUCCEEDED(pFrames->get_Item(&vFrame, &ret)))
{
IHTMLWindow2 *pWindow = NULL
if(SUCCEEDED(ret.pdispVal->QueryInterface(IID_IHTMLWindow2,
(LPVOID*)&pWindow)))
{
IHTMLDocument2 *pDoc = NULL;
if(SUCCEEDED(pWindow->get_document(&pDoc)))
{
// pDoc points to the actual document contained in
the specified frame
IPersistFile *PersistFile = NULL;
if(SUCCEEDED(pDoc->QueryInterface(IID_IPersistFile,
(LPVOID*)PersistFile)))
{
PersistFile->Save(WideString("temp.txt"), true);
PersistFile->Release();
}
pDoc->Release();
}
pWindow->Release();
}
}
pFrames->Release();
}
HTMLDocument->Release();
}
Gambit
임세솬 님이 쓰신 글 :
: 이 컴포넌트로 웹소스를 읽어올수 있었는데
: 문제는 frame으로 된 사이트는 프레임소스만 달랑 나올뿐
: 실제 내부소스는 나오지 않네요
:
: 좋은 방법이 있을까요?
: 프레임을 구성하는 소스까지 읽어올 방법..
:
: void __fastcall TForm1::CppWebBrowser1DocumentComplete(TObject *Sender,
: LPDISPATCH pDisp, Variant *URL)
: {
: Variant vaDocument = CppWebBrowser1->Document;
: AnsiString stSource;
:
: if (!vaDocument.IsEmpty()) {
: stSource = vaDocument.OlePropertyGet("documentElement").OlePropertyGet("outerhtml");
: }
:
: Memo1->Clear();
: Memo1->Lines->Add(stSource);
: }
:
: 이렇게 하면 소스는 나오지만 프레임으로 구성한 사이트의 경우 소스가 나오지 않고
: 프레임소스만 출력됨 , 하지만 저는 실제 화면에 보이는 소스를 읽어야 하는데
: 방법이 없네여 . 도와주십시오.
|