用c++Builder 怎么获取html内容

2021-05-07 01:29

阅读:748

标签:returns   put   substr   bbr   tca   tco   ref   nsis   ida   

https://zhidao.baidu.com/question/987621988648642499.html

 

CppWebBrowser的使用三 获取表单内容bai
主要函du数如下:
AnsiString __fastcall TMainForm::GetFormValue(TCppWebBrowser *CppWebBrowser1, AnsiString ActionStr)
{
//赋值
AnsiString MyStr = ActionStr;
AnsiString SName,SId,SValue;
AnsiString ReturnStr; //返回值
ReturnStr = "";
SName = MyStr.SubString(1,MyStr.Pos(",")-1);
MyStr = MyStr.SubString(MyStr.Pos(",") 1,MyStr.Length()-MyStr.Pos(","));
SId = MyStr.SubString(1,MyStr.Pos(",")-1);
SValue = MyStr.SubString(MyStr.Pos(",") 1,MyStr.Length());
if(SValue==NULL)SValue="";
VARIANT id, index,id1,index1;
IDispatch *spDispatch;
IHTMLDocument2 *pDoc2;
IHTMLElement *pElement;
IHTMLElementCollection *pElementCol;
IHTMLFormElement *pFormElement;
IHTMLInputElement *pInputElement;//Input
IHTMLTextAreaElement* pTextAreaElement;// TextArea
IDispatch *WebDocument=static_cast(CppWebBrowser1->Document);
pDoc2=static_cast(WebDocument);
//首先获取zhiIWebBrowser2接口
if (SUCCEEDED(pDoc2->get_forms(&pElementCol))) //得到form
{
long p=0;
if(SUCCEEDED(pElementCol->get_length(&p))) //哪一个daoform
if(p!=0)
{
for(long i=0;i{
V_VT(&id) = VT_I4;
V_I4(&id) = i;
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
if(SUCCEEDED(pElementCol->item(id,index, &spDispatch)))
{
if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLFormElement,(void**)&pFormElement)))
{
long q=0;
if(SUCCEEDED(pFormElement->get_length(&q))) //得到form中的控件个数
for(long j=0;j{
V_VT(&id) = VT_I4;
V_I4(&id) = j;
V_VT(&index) = VT_I4;
V_I4(&index) = 0;
if(SUCCEEDED(pFormElement->item(id,index, &spDispatch)))
{
if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLElement,(void**)&pElement)))

用c++Builder 怎么获取html内容

标签:returns   put   substr   bbr   tca   tco   ref   nsis   ida   

原文地址:https://www.cnblogs.com/suhq/p/13187112.html


评论


亲,登录后才可以留言!