zoukankan      html  css  js  c++  java
  • 用c++Builder 怎么获取html内容

    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<IDispatch*>(CppWebBrowser1->Document);
    pDoc2=static_cast<IHTMLDocument2*>(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<=(p-1);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<=(q-1);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)))

  • 相关阅读:
    AWTK-MVVM:用 C 语言实现 Model
    MTU1500情况下,发送1460和1448长度数据
    linux mtu =1500情况下tcpdump抓包分析
    自己总结的pycharm超常用快捷键
    ICMP协议是IP层协议
    IP 分段
    ubuntu18.04安装中文输入法
    tcp 窗口大小
    flask学习笔记(二)
    开始学习前的环境安装
  • 原文地址:https://www.cnblogs.com/suhq/p/13187112.html
Copyright © 2011-2022 走看看