我把构建好的语句放到IE上能登录,可是用POST就是不行,下面是代码,望能够得到解决.procedure TForm1.btnLoginClick(Sender: TObject); 
var 
  s, Response: TStringStream; 
  i: Integer; 
begin 
  s := TStringStream.Create(''); 
  Response := TStringStream.Create(''); 
  try 
    s.WriteString('&TPL_username=用户名); 
    s.WriteString('&TPL_password=密码'); 
    s.WriteString('&Submit=登 录'); 
    s.WriteString('&CtrlVersion=1,0,0,7'); 
    s.WriteString('&support=000001'); 
    s.WriteString('&tid='); 
    s.WriteString('&actionForStable=enable_post_user_action'); 
    s.WriteString('&TPL_redirect_url='); 
    s.WriteString('&event_submit_do_login=anything'); 
    s.WriteString('&abtest='); 
    s.WriteString('&pstrong='); 
    s.WriteString('&from='); 
    s.WriteString('&yparam='); 
    s.WriteString('&done='); 
    http.HandleRedirects:=true; 
http.Request.Connection:='Keep-Alive'; 
http.Request.CacheControl:='no-cache'; 
http.Request.Accept:='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, */*'; 
http.Request.ContentType:= 'application/x-www-form-urlencoded'; 
http.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)'; 
http.Request.host:='member1.taobao.com'; http.Request.Referer:='http://member1.taobao.com/member/login.jhtml'; 
    try 
      http.Post('http://member1.taobao.com/member/login.jhtml', s, Response) 
    except 
      http.Get(http.Response.Location, Response); 
    end; 
    
    //Memo1.Lines.Text:=http.Get('http://auction1.taobao.com/auction/goods/goods_on_sale.htm'); 
    Memo1.Lines.Text := Response.DataString;   finally 
    s.Free; 
    Response.Free; 
  end; end; 

解决方案 »

  1.   

    s.WriteString('&TPL_username=用户名); 
    这句不出错?
      

  2.   


    unit Unit7;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,ComObj;type
      TForm7 = class(TForm)
        Memo_Log: TMemo;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form7: TForm7;implementation{$R *.dfm}function ADOStreamDecode(const S:Variant):string;
    var
      Obj:OleVariant;
    begin
      Obj:=CreateOleObject('Adodb.Stream');
      try
        Obj.Type :=1;
        Obj.Mode :=3;
        Obj.Open;
        Obj.Write(S);
        Obj.Position:= 0;
        Obj.Type := 2;
        Obj.Charset :='GB2312';
        Result := Obj.ReadText;
      finally
        Obj.Close;
        Obj:=Unassigned;
      end;
    end;procedure TForm7.Button1Click(Sender: TObject);
    var
      FHTTPObj:OleVariant;
      _PostStr:OleVariant;
    begin
      FHTTPObj:=CreateOleObject('WinHttp.WinHttpRequest.5.1');
      try
        _PostStr:='TPL_username=用户名&CtrlVersion=1,0,0,7&support=000001&'+
        'tid=加密后的&'+
        'TPL_password=加密后的&'+
        'actionForStable=enable_post_user_action&action=Authenticator&'+
        'TPL_redirect_url=&event_submit_do_login=anything&abtest=&pstrong=&'+
        'from=&yparam=&done=';
        //FHTTPObj.Option(6):=0;//禁止Location
        FHTTPObj.setTimeouts(10000,10000,10000,10000);
        FHTTPObj.Open('POST', 'http://member1.taobao.com/member/login.jhtml', False);
        FHTTPObj.SetRequestHeader('Content-Type','application/x-www-form-urlencoded');
        FHTTPObj.SetRequestHeader('Content-Length',Length(_PostStr));
        FHTTPObj.send(_PostStr);
        Memo_Log.Text:=ADOStreamDecode(FHTTPObj.ResponseBody);
      finally
        FHTTPObj:=Unassigned;
      end;
    end;end.
    TPL_username,tid,TPL_password 都是加密后的,可以用HTTPAnaly去分析协议,正确的话,结贴散分啊
      

  3.   

    这个方法不错,用IDHTTP解决,我还是搞不定呢,100分啊
    http://topic.csdn.net/u/20090208/23/1614995e-0017-4475-b884-95512e96278f.html