mshtml一些用法
来源:互联网 发布:小程序三级分销源码 编辑:程序博客网 时间:2024/06/15 09:20
获取某个tags集合
CString allPointData;
IDispatch *pDisp = webbrowser.get_Document();
IHTMLDocument2* pDocument;
IHTMLElementCollection* pCollection;
pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDocument);
HRESULT hr;
hr = pDocument->get_all(&pCollection);
//hr=pDocument->get_scripts(&pCollection);
VARIANT varID;
varID = StringToVariant((CString)"TABLE");
pCollection->tags(varID,&pDisp);
IHTMLElementCollection* Collection;
pDisp->QueryInterface(&Collection);
long celem;
Collection->get_length(&celem);
IHTMLScriptElement用法
CString allPointData;
IDispatch *pDisp = webbrowser.get_Document();
IHTMLDocument2* pDocument;
IHTMLElementCollection* pCollection;
pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDocument);
HRESULT hr;
hr = pDocument->get_all(&pCollection);
//hr=pDocument->get_scripts(&pCollection);
//VARIANT varID;
// varID = StringToVariant((CString)"TABLE");
//pCollection->tags(varID,&pDisp);
//IHTMLElementCollection* Collection;
//pDisp->QueryInterface(&Collection);
long celem;
//Collection->get_length(&celem);
if( hr == S_OK )
{
hr = pCollection->get_length(&celem); //得到所有节点的个数用以遍历
if( hr == S_OK )
{
VARIANT varIndex, var;
for ( int i = 0; i < celem; i++ )
{
varIndex.vt = VT_UINT;
varIndex.lVal = i;
VariantInit(&var);
hr = pCollection->item(varIndex,var,&pDisp);
if ( hr == S_OK )
{
//IHTMLElement *pElement;
IHTMLScriptElement *pScriptElement;
hr = pDisp->QueryInterface(IID_IHTMLScriptElement,(void**)&pScriptElement);
if ( hr == S_OK )
{
CString pointData,id;
BSTR bs= SysAllocString(L"");
//pElement->get_id(&bs);
//pElement->get_className(&bs);
pScriptElement->get_src(&bs);
id = CString(bs);
if ( id == _T("d:\ni.js"))
{
//IHTMLInputElement* input;
//hr = pDisp->QueryInterface(IID_IHTMLInputElement,(void**)&input);
//input->get_value(&bs); //将id为LanLonPoints中的value值赋给bs
//pointData = CString(bs);
//allPointData = pointData;
VARIANT index;
VARIANT varID;
V_VT(&index) = VT_I4;
V_I4(&index) = 1;
CString strInfo;
IHTMLTable * pTable; // 获得表格元素接口
hr = pDisp->QueryInterface(IID_IHTMLTable,(void **)&pTable );
if ( (hr == S_OK) && (pTable != NULL) )
{
IHTMLElementCollection* pColl2 = NULL;
pTable->get_rows(&pColl2); // 获取表格行
IDispatch* pDisp2;
V_I4(&index) = 1;
hr = pColl2->item( index,index, &pDisp2 ); // 获取第2行位置
if ( (hr == S_OK) && (pDisp2 != NULL) )
{
IHTMLTableRow* pRow; // 获取行元素接口
hr = pDisp2->QueryInterface(IID_IHTMLTableRow,(void **)&pRow);
if( (hr == S_OK) && (pRow != NULL) )
{
IHTMLElementCollection* pColl3 = NULL;
pRow->get_cells(&pColl3); // 获取格子元素
IDispatch* pDisp3;
V_I4(&index) = 1;
hr = pColl3->item( index,index, &pDisp3 ); // 获取第2行第2格元素
if ( (hr == S_OK) && (pDisp2 != NULL) )
{
IHTMLElement* pElem; // 获取元素接口
hr = pDisp3->QueryInterface(IID_IHTMLElement,(void **)&pElem);
if( hr == S_OK )
{
BSTR bstr = SysAllocString(L"");
pElem->get_innerText(&bstr); // 获取该表格元素的文本信息
strInfo =bstr;
//MessageBoxExA(NULL,strInfo,NULL,NULL,NULL);
pElem->Release();
}
pDisp3->Release();
}
pRow->Release();
}
pDisp2->Release();
}
pTable->Release();
}
pDisp->Release();
}
}
}
}
}
}
- mshtml一些用法
- 在Delphi中使用IDispatch访问MSHTML的一些经验
- 关于MSHTML
- MSHTML Overviews
- MSHTML Reference
- mshtml相关
- 【转载】关于MSHTML
- MSHTML innerhtml属性
- DHTML Process Using MSHTML
- ++ 使用MSHTML分析html
- CheckListBox的一些用法!
- 关于SqlDataReader一些用法
- pMock 中的一些用法...
- select 一些用法
- printf的一些用法
- javascript 一些基本用法
- 一些js基本用法
- [摘]SHBrowseForFolde 一些用法!!
- MySQL子查询很慢的问题
- DWREngine.setAsync(false)
- javascript通过className獲取文件元素
- Mysql 相关
- change exist Android branch to other branch
- mshtml一些用法
- C++第16周项目2——带姓名的成绩单(字符数组版)
- linux配置java环境变量(详细)
- IEnumerable和IEnumrator用法
- 局域网SOCKET通信(TCP)需要心跳包来保持长连接么
- Spring引用外部文件生成主键配置
- [转]大网站都用什么操作系统与 Web 服务器 ?
- JQuery常用方法一览
- 指定用户名登录mysql