如何使用c++builder操作网页
c++builder能像vb这样操作页面吗
Dim Doc As HTMLDocument Set Doc = Web1(i).Document If Doc Is Nothing Then Exit Sub Dim txtID As HTMLInputElement Set txtID = Doc.getElementById("loginID") txtID.Value = Text1.Text Dim txtPSW As HTMLInputElement Set txtPSW = Doc.getElementById("password") txtPSW.Value = Text2.Text Dim btnLog As HTMLButtonElement Dim btns As IHTMLElementCollection Set btns = Doc.getElementsByTagName("button") Dim j As Long For j = 0 To btns.length - 1 If btns.Item(j).Value = "登录" Then Set btnLog = btns.Item(j) Exit For End If Next j
Variant document; document=CppWebBrowser1-> Document; Variant vAllTag = document.OlePropertyGet("All"); // 填充页面中的用户名框 document.OlePropertyGet("loginID").OlePropertySet("InnerText",usrname.c_str()); // 填充页面中的密码框, document.OlePropertyGet("password").OlePropertySet("InnerText",password.c_str()); // 执行页面中Form的提交方法 Variant Btns=vAllTag.OlePropertyGet("btn_login"); long btncount = Btns.OlePropertyGet("length"); Variant eachbtn; for (int i=0;i<btncount;i++) { eachbtn = Btns.OleFunction("item",i); //依序取得每一個链接 if (eachbtn.OlePropertyGet("innerText")==(Variant)"登录") //判断中的文字 { eachbtn.OleFunction("click"); //按下链接 break; } }