用CppWebBrowser读写html元素值
来源:互联网 发布:sql语句教程 编辑:程序博客网 时间:2024/05/16 13:44
#include <mshtml.h>void __fastcall TForm1::Button6Click(TObject *Sender){ IHTMLDocument3 *pDocument; IHTMLElement *htmlbody; BSTR title,htmlsource,content; AnsiString id; HRESULT hr; hr = CppWebBrowser1->Document->QueryInterface(IID_IHTMLDocument3,(void**)&pDocument) ; if( !SUCCEEDED(hr) ) { return ; } id = "we"; //元素的ID title = WideString(id).c_bstr();//转成wchar_t pDocument->getElementById(title,&htmlbody);//定位元素 htmlbody->get_outerHTML(&htmlsource); //获取整个标签代码<p id="we">hello</p> htmlbody->put_innerText(L"how are you"); //写数据,将we换成how are you htmlbody->get_innerText(&htmlsource); //获取hello ShowMessage(htmlsource);}
如果是用javascript修改网页中的元素值,如下:
function setlable(){ document.getElementById('we').innerHTML="bbbbb";}
然后用脚本接口调用。
0 0
- 用CppWebBrowser读写html元素值
- 读写HTML元素的css 属性
- jQuery 入门教程(17): 读写HTML元素的css 属性
- jQuery 入门教程(17): 读写HTML元素的css 属性
- php 获取HTML元素值
- 用Javascript删除HTML元素
- HTML 元素
- HTML元素
- Html元素
- html元素
- HTML 元素
- HTML元素
- HTML元素
- html元素
- html元素
- html 元素
- html元素
- HTML 元素
- 那些曾经的互联网草根牛人
- 一次线上运营活动实操
- DLL函数导出类型
- IOS5 ARC unsafe_unretained等说明
- SQL Server 2008 1433端口启用的解决方案
- 用CppWebBrowser读写html元素值
- 设计模式之三个工厂
- 动态计算UITableViewCell高度详解
- 迭代二总结--包煜
- EGL接口介绍
- odbcad32.exe ODBC 32 and 64 bit version
- 《程序员 你伤不起》读后感(一)
- dom4j基础教程
- Windows下 maven3.0.4的安装步骤+maven配置本地仓库