首页 > Web开发 > 详细

浏览器插件获取网页内容

时间:2014-07-28 00:10:10      阅读:677      评论:0      收藏:0      [点我收藏+]
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();


 
}

浏览器插件获取网页内容,布布扣,bubuko.com

浏览器插件获取网页内容

原文:http://blog.csdn.net/loveheronly/article/details/38172487

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!