比如说,找到了这个网页(CSDN的用户登录的页面)
http://passport.csdn.net/UserLogin.aspx想通过一个外部程序来触发该页面的登录事件。即:如何通过点击一个按钮,使程序填入该页面的用户名、密码(用户名,密码已知,暂时不管验证码),来触发这个网页的登录事件?希望能提供一个例子。
谢谢!

解决方案 »

  1.   

    var
    o : Olevariant;
    o := WebBrowser1.OleObject.document.all.item('User_Id',0);   //找到登录用户名的输入框
    //o.value := '0096';
    o.value :=id;
    o := WebBrowser1.oleobject.document.all.item('password',0); //找到登录密码的输入框
    //o.value := '0096';
    o.value :=password;
    //WebBrowser1.oleobject.document.Forms.Item('btn_Sure', 0).submit;          //第一个表单提交
    //{
    o := WebBrowser1.oleobject.document.all.item('btn_Sure',0);          //或者用指定表单名称提交
    o.Click;
      

  2.   

    请问webBrower1可否再详细一些?
    谢谢!
      

  3.   

    以下是部分代码,你可以做适当的更改
    var
      iDoc: IHtmlDocument2;
      i,j: integer;
      ov: OleVariant;
      iDisp: IDispatch;
      iColl: IHTMLElementCollection;
      InputImage: HTMLInputImage;WebBrowser1.ControlInterface.Document.QueryInterface(IHtmlDocument2, iDoc);
              if Assigned(iDoc) then
              begin
                ov := 'INPUT';
                iDisp := iDoc.all.tags(ov);
                if Assigned(IDisp) then
                begin
                  IDisp.QueryInterface(IHTMLElementCollection, iColl);
                  if Assigned(iColl) then
                  begin
                    j := iColl.Get_length;
                    for i := 1 to j do
                    begin
                      iDisp := iColl.item(pred(i), 0);
                      iDisp.QueryInterface(HTMLInputImage, InputImage);
                      if Assigned(InputImage) then
                      begin
                        if InputImage.name ='UserName' then
                          InputImage.setAttribute('value',frmMain.EdtUser.Text,0);
                        if InputImage.name='PassWord' then
                          InputImage.setAttribute('value',frmMain.EdtPassword.Text,0);
                        if InputImage.name = 'Button' then
                        begin
                          InputImage.Click;  // ------------模拟点击
                        end;
                      end;
                    end;
                  end;
                end;
      

  4.   

    请问哪里有Twebbrowser的教程?
    或者哪本书上有,请指点一下。
      

  5.   

    一个更简单的办法,直接POST数据,这样更有通用性。