HTML文本载入HTMLDocument2进行解析

更多精彩内容,请见:http://www.16boke.com

IHTMLDocument2 *pDoc;
IHTMLElementCollection *objAllElement;
HRESULT hr;
CoInitialize(NULL);
hr = CoCreateInstance(CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER,
IID_IHTMLDocument2, (void**)&pDoc);
SAFEARRAY* psa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
VARIANT *param;
bstr_t bsData = (LPCTSTR)pBuffer;//wchar_t *pBuffer;页面源码
hr = SafeArrayAccessData(psa, (LPVOID*)¶m);
param->vt = VT_BSTR;
param->bstrVal = (BSTR)bsData;
hr = pDoc->write(psa);
hr = pDoc->close();
pDoc->get_all(&objAllElement);

至此html文件已经载入HTMLDocument2,解析代码参考上一篇:《利用WebBrowser控件实现百度自动搜索

更多精彩内容,请见:http://www.16boke.com

你可能感兴趣的:(HTML文本载入HTMLDocument2进行解析)