在Windows mobile 6.0中获取网页文档
在互联网上进行大量搜索后,我们发现以下代码仅将网页的正文部分加载到网络浏览器控件上,
IPIEHTMLDocument2 *pHTMLDocument;
IPIEHTMLElement* pBodyElement;
CComPtr<IDispatch> spDispDoc;
HRESULT res = m_spWebBrowser2->get_Document(&spDispDoc);
if(SUCCEEDED(res))
{
spDispDoc->QueryInterface( __uuidof(IPIEHTMLDocument2), (void**)&pHTMLDocument);
WCHAR szText[256];
DISPID id;
OLECHAR FAR* szTemp;
// store "body"
szTemp = szText;
StringCchPrintf(szText, 256, L"body", id);
// get the body
pHTMLDocument->GetIDsOfNames(IID_NULL, &szTemp, 1, LOCALE_USER_DEFAULT, &id);
VARIANT varResult;
varResult.vt = VT_DISPATCH;
VARIANT FAR *pVarResult = &varResult;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
pHTMLDocument->Invoke(id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispparamsNoArgs, pVarResult, NULL, NULL);
BSTR bodyValue;
if( NULL != pVarResult->pdispVal)
{
pVarResult->pdispVal->QueryInterface(IID_IPIEHTMLElement, (void**)&pBodyElement);
pBodyElement->get_innerHTML(&bodyValue);
}
}
但是现在我们如何从加载的网页中获取剩余的头部和其他标记文档文本, 即使我们尝试将“head”字符串传递给 GetIDsOfNames() 方法,它也会传递失败值,所以我们感到震惊。 请向我们提供在windows mobile 6.0中访问/提取整个网页内容的方法
谢谢, 拉马南德·巴特.
After searching lot on the internet we have found following code to get only body part of the web page loaded onto web browser control
IPIEHTMLDocument2 *pHTMLDocument;
IPIEHTMLElement* pBodyElement;
CComPtr<IDispatch> spDispDoc;
HRESULT res = m_spWebBrowser2->get_Document(&spDispDoc);
if(SUCCEEDED(res))
{
spDispDoc->QueryInterface( __uuidof(IPIEHTMLDocument2), (void**)&pHTMLDocument);
WCHAR szText[256];
DISPID id;
OLECHAR FAR* szTemp;
// store "body"
szTemp = szText;
StringCchPrintf(szText, 256, L"body", id);
// get the body
pHTMLDocument->GetIDsOfNames(IID_NULL, &szTemp, 1, LOCALE_USER_DEFAULT, &id);
VARIANT varResult;
varResult.vt = VT_DISPATCH;
VARIANT FAR *pVarResult = &varResult;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
pHTMLDocument->Invoke(id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &dispparamsNoArgs, pVarResult, NULL, NULL);
BSTR bodyValue;
if( NULL != pVarResult->pdispVal)
{
pVarResult->pdispVal->QueryInterface(IID_IPIEHTMLElement, (void**)&pBodyElement);
pBodyElement->get_innerHTML(&bodyValue);
}
}
But now how we get the remaining head and other tag document text from the loaded web page,
even we have tried passing "head" string to the GetIDsOfNames() method and it passes fail value, so we are struck.
Please provide us the method to access/ extract entire web page content in windows mobile 6.0
Thanks,
Ramanand Bhat.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上述
代码获取windows mobile设备上的整个网页内容。
}
Above mentioned code gets the entire web page content in windows mobile devices.