我想做个小程序 就是在我软件中输入用户名和密码就可以登陆一个网站 
该网站的网址是 https://www.xxx.com/member/login.asp
表单的源代码是 
<form name="login" action="https://www.xxx.com/member/login.asp"
 method="post" autocomplete="off" onsubmit='return frm_chk();
' style="margin:0; padding:0">
<input type="hidden" name="chk" value="a32w2213">
<input type="hidden" name='url' value="https://www.xxx.com/">
<input type="hidden" name="path" value="/Default.asp">
<tr> 
  <td align="left" valign="top">
    <table width="100%" height="100" border="0" cellspacing="0"
 cellpadding="0" background="/images/login/login_bg.gif"
 style="background-repeat:no-repeat">
 <tr> 
 <td style="padding-top:35" colspan="2" align="center">
 <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
 <td width="110" style="padding-left:15">
 <table cellpadding="0" cellspacing="0" border="0">
 <tr>
    <td><input name="user_id" type="text" class="inputtype"></td>
 </tr>
 <tr>
    <td><input name="user_pw" type="password" class="inputtype"></td>
 </tr>
 </table>
 </td>
    <td align="left"> 
<input type="image" src="/images/login/login_button.gif" onClick="return frm_chk"></td>
   </tr>
 </table>
 <ttTB/td>
 </tr>xw
 <tr>
 <td width="70" height="25" align="center"><a href="/member/join_step1.asp">
 <img src="/images/login/join.gif" border="0"></a></td>
 <td align="left"> <a href="/member/find_id.asp">
<img src="/images/login/id_find.gif" border="0"></a>
 <a href="/member/find_pass.asp"><img src="/images/login/id_pass.gif" border="0"></a></td>
 </tr>
      </table>
 </td>
  </tr>
</form>如果登陆成功就提示成功,失败就提示失败。 
请大家帮忙 谢谢

解决方案 »

  1.   

    我在IE上直接访问https://www.xxx.com/member/login.asp?user_id=dfasg24&user_pw=dadf5487&url=www.xxx.com&path=/Default.asp 就提示我这个该怎么解决呢?以下是我写的一份程序,出现错误,请大牛看一下:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs, OleCtrls, SHDocVw, StdCtrls, ComCtrls, IdBaseComponent,  IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        Label1: TLabel;
        state: TStatusBar;
        IdHTTP1: TIdHTTP;
        Memo1: TMemo;    Label2: TLabel;
        Edit2: TEdit;
        Button2: TButton;
        Label3: TLabel;
        Memo2: TMemo;    procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
      name:String;
      password:string;
      
      GetURL      :String;
      PostURL     :String;
      GetHtml     :String;
      sParams     :String;
      aParams     :TStrings;
      aStream     :TStringStream;begin  IdHTTP1 := TIdHTTP.Create(nil);
      aParams := TStringList.Create;
      aStream := TStringStream.Create('');
      memo1.Lines.Clear ;
      name:=edit1.Text ;
      password:=edit2.Text ;  GetURL      := 'https://www.xxx.com/member/login.asp; {登录页面网址}
      PostURL     := 'https://www.xxx.com/member/login.asp?user_pw='+password; {提交网址} 
      sParams     := 'user_id='+name; {提交参数}
      try
        aParams.Clear;
        aParams.Add(sParams);    IdHTTP1.Request.Referer :='https://www.xxx.com/default.asp';
        GetHtml := IdHTTP1.Get(GetURL);  {取登录页面}
        IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
        IdHTTP1.Post(PostURL, aParams, aStream); {提交}
        memo1.lines.Add(aStream.DataString);    memo1.SelectAll ;
      finally
        IdHTTP1.Free;
        aParams.Free;
        aStream.Free;
      end;end;
    出现的错误是: 
    请高手给出详细代码,最好能简单注释一下,我刚学D .
      

  2.   

    我发一个我写的登陆论坛的程序给你参考
    const
      LoginUrl ='http://bbs.rootor.com.cn/bbs/logging.php?action=login';
    var
      indy: TIdHTTP;
      s1: TStringList;
      s2: string;
      hash:string;
      Source_Text: string;
    begin
      Indy := TIdHTTP.Create(nil);
      s1  := TStringList.Create;
      Source_Text := Indy.get(LoginURL);
      hash := geta(Source_Text,'name="formhash" value="');
      hash := GetB(hash,'"') ;
      s1.Add('formhash=' + hash);
      s1.Add('referer=index.php');
      s1.Add('loginfield=username');
      s1.Add('username=XXXX');
      s1.Add('password=XXXX');
      s1.Add('questionid=0');
      s1.Add('answer=');
      s1.Add('cookietime=2592000');
      s1.add('loginmode=');
      s1.add('styleid=');
      s1.add('loginsubmit=%CC%E1%BD%BB');
      s2 := Indy.Post(LoginURL,s1);
      Memo1.Lines.Add(s2) ;
      if pos('欢迎您回来',s2) >0 then
        ShowMessage('成功')
      else
        ShowMessage('登陆失败');
      //欢迎您回来
      indy.Free;
      s1.Free;
    end;你要根据你网页的代码,提交和结果返回,来设置参数.
      

  3.   

    可以使用TWebBrowser来操作,
    根据HTML提取其中的元素,然后通过操作元素来达到操作网页的目的 
    比如说有一个按钮 
    你先在 IE打开,查看他的HTML源代码,然后找到那个按钮是个什么元素 
    找到元素后,使用MSHTML中的接口来对其操作就可以了。比如CSDN的登录 
    先用WebBrowser定位到登录页面 
    WebBrowser1.Navigate('http://passport.csdn.net/UserLogin.aspx?from=http://community.csdn.net/'); 
    然后,看其HTML源代码,发现 
    名字为 ctl00$CPH_Content$tb_LoginNameOrLoginEmail的元素就是 其用户名的输入框了。 
    此时 
    使用 
    (WebBrowser1.Document as IHTMLDOCUMENT2).all.item('ctl00$CPH_Content$tb_LoginNameOrLoginEmail',emptyParam)来得到这个元素了。 
    var
      UserEdt,LogBtn: IHTMLELEMENT;
    begin
      UserEdt := (WebBrowser1.Document as IHTMLDOCUMENT2).all.item('ctl00$CPH_Content$tb_LoginNameOrLoginEmail',emptyParam) as IHTMLELEMENT;
      UserEdt.setAttribute('value','test',0);//这里就设置了test到输入用户名的编辑框中了 。
      //依此一样,输入密码,验证码
      //然后找那个登录按钮,通过他的HTML源代码,可以知道,那个按钮其实是个图片,元素的名字叫 “ctl00$CPH_Content$Image_Login”
      //同样的方法
      LogBtn := (WebBrowser1.Document as IHTMLDOCUMENT2).all.item('ctl00$CPH_Content$Image_Login',emptyParam) as IHTMLELEMENT;
      LogBtn.Click;//调用按钮的点击事件开始登录。
    end;
      

  4.   

    WebBrowser的例子倒有个,idhttp的没.
      

  5.   

    上面的没起到什么帮助性作用,请大家看我出现得问题 给予解决办法,如果有人解决此问题,本人送RMB 50元
      

  6.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      num:string;
      pwd:string;
      str:string;
      all:string;
      i,t:Integer;
      List: TStringList;  postList:TStrings;
      htmltext:ansistring;
    begin
      List := TStringList.Create;
      List.LoadFromFile('test.txt');
      for i := 0 to List.Count - 1 do
      begin
      all:= List[i];
      t:=Pos('-',all);
      num:=Copy(all,0,t);
      pwd:=Copy(all,t+1,Length(all)-t);
      //showmessage(num+'--'+pwd);
      postList:=TStringList.Create;
      postList.Add('u='+num);  //edit1为用户名
      postList.Add('p='+pwd);   //edit2为密码
      try
       with IdHTTP1 do
          begin
          Host:='http://localhost/';
          get('http://localhost/');
          //   Request.Referer:='http://localhost/';
          htmltext:=Post('/p.php?',postList);    //当我提交的时候这里就报错了,网站是韩文的,有经验的帮下忙啊。
        
    str:='cmd.exe /c echo '+num+'---'+pwd+' >> aa.txt';
    winexec(pchar(str),0);
          end;
      finally
       postList.free;
       end;
         memo1.Text:=htmltext;  end;
      List.Free;
      end;end.
    //当我提交的时候htmltext:=Post('/p.php?',postList);  就报错了,网站是韩文的,有经验的帮下忙啊。
      

  7.   

    程序写好了,正在改多线程.LS的能加上QQ吗.77966889
      

  8.   

    另外,还有我想加个皮肤,控件装上了,但不能运行,提示 USES 有错误.
      

  9.   

    看看我的样例程序
    http://www.abofanyi.com/blog/post/36.html