获取网页中的内容(CDHtmlDialog)

获取网页中的内容(CDHtmlDialog)

 

// Visual Studio Samples/1033/AllVCLanguageSamples/C++/MFC/internet/DHtmlExplore/DHtmlExploreDlg.cpp void CDHtmlExploreDlg::OnBnClickedButton1() { // <div id="DivText"></div> CComPtr<IHTMLElement> DivText; GetElementInterface(_T("DivText"), IID_IHTMLElement, (void **) &DivText); if (DivText) { CComBSTR value; DivText->get_innerHTML(&value); //BSTR s = L"<a href="/" mce_href="/""http://g.cn/">google</a> </p>"; value += L"<a href="/" mce_href="/""http://www.google.com/">google</a>"; DivText->put_innerHTML(value); } // <span id="SpanText">121</span> CComPtr<IHTMLElement> span; GetElementInterface(_T("SpanText"), IID_IHTMLElement, (void **) &span); if (span) { CComBSTR value; span->get_innerHTML(&value); value += L"-"; span->put_innerHTML(value); } // <input id="CkbOpen" type="checkbox"> CComPtr<IHTMLInputElement> CkbOpen; GetElementInterface(_T("CkbOpen"), IID_IHTMLInputElement, (void **) &CkbOpen); if (CkbOpen) { VARIANT_BOOL b; CkbOpen->get_checked(&b); b = !b; CkbOpen->put_checked(b); } // <input id="BtnOK" value="确定" type="button"> //CComPtr<IHTMLButtonElement> BtnOK; //GetElementInterface(_T("BtnOK"), IID_IHTMLButtonElement, (void **) &BtnOK); CComPtr<IHTMLInputElement> BtnOK; GetElementInterface(_T("BtnOK"), IID_IHTMLInputElement, (void **) &BtnOK); if (BtnOK) { CComBSTR value; BtnOK->get_value(&value); if (value == L"确定") BtnOK->put_value(L"取消"); else BtnOK->put_value(L"确定"); } }

你可能感兴趣的:(获取网页中的内容(CDHtmlDialog))