请教如何用webbrowser自动登录淘宝,请各位大侠给点思路

解决方案 »

  1.   

    用idhttp吧,已经搞定,web也可以,就是找到那连个框框,填写好并提交
      

  2.   

    1. 抓包看发送的参数,然后用webbrowser发送数据2. 用webbrowser打开登录页面,给用户名密码框赋值,然后模拟点击按钮
      

  3.   

    我想要在webbrowser上自动登录啊,我需要能看到网页的
      

  4.   

    unit Unit1; interface uses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,  StdCtrls; type  TForm1 = class(TForm)    mmo1: TMemo;    btn1: TButton;    IdHTTP1: TIdHTTP;    Label1: TLabel;    Edit1: TEdit;    Label2: TLabel;    Edit2: TEdit;    procedure btn1Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end; var  Form1: TForm1; implementation {$R *.dfm} procedure TForm1.btn1Click(Sender: TObject);var  code: string;  done: Boolean;  postList: TStrings;  Response: TStringStream;begin  mmo1.clear;   // 开始登录代码  Response := TStringStream.Create('', TEncoding.UTF8);  postList := TStringList.Create;  try    IdHTTP1.HandleRedirects := True;     postList.add('cktime=31536000');    postList.add('forward=');    postList.add('hideid=0');    postList.add('jumpurl=http://bbs.hualongxiang.com/index.php');    postList.add('lgt=0');    postList.add('pwpwd='+edit2.Text );    postList.add('pwuser='+edit1.Text );    postList.add('step=2');    postList.add('submit=¼');     IdHTTP1.Post('http://bbs.hualongxiang.com/login.php?', postList, Response);    done := True;  except    done := false;  end;   if (done) and (Pos('200 OK', IdHTTP1.ResponseText) <> 0) then  begin    code := IdHTTP1.Get('http://bbs.hualongxiang.com/index.php');    mmo1.lines.add(code);  end  else  begin    mmo1.lines.add('logon error,error code:' + IdHTTP1.Response.RawHeaders.Text);  end;  Response.Free;  postList.Free; end;   end.
      

  5.   


    用webbrowser发送数据不行吗?这个也能看见网页啊
      

  6.   

    URL := 'http://login.taobao.com/member/login.jhtml';
      wbTaoBao.Navigate(loginUrl);
      strPostData := 'TPL_username=ujjcel&TPL_password=hot9988&' +
                     'actionForStable=enable_post_user_action&' +
                     'action=Authenticator&mi_uid=&mcheck=&' +
                     'TPL_redirect_url=http%3A%2F%2Fi.taobao.' +
                     'com%2Fmy_taobao.htm%3Fnekot%3DdmJsb2Fk1272686739178&_oooo_' +
                     '=http%3A%2F%2Fi.taobao.com%2Fmy_taobao.htm%3Fnekot%3DdmJsb2Fk1' +
                     '272686739178&event_submit_do_login=anything&abtest=&pstrong=2&' +
                     'from=&yparam=&done=&loginType=3&tid=&support=000001&CtrlVersion=1%2C0%2C0%2C7&loginFromCount=tbBeta';
      strHEAD := 'Content-Type:application/x-www-form-urlencoded';
      wbTaoBao.Navigate(Url, EmptyParam, EmptyParam, strPostData, strHEAD);
      

  7.   


    //枚举组件,这个不是淘宝的,我找到的是'ATL:Edit',你用spy++查一下
    function   EnumChildProc(
        hwnd:   HWND;
        lParam:   LPARAM
    ):   BOOL;   stdcall;
    var
        vBuffer:   array[0..255]   of   Char;
    begin
        PInteger(lParam)^   :=   0;
        GetClassName(hwnd,   vBuffer,   SizeOf(vBuffer));
        if   SameText( 'ATL:Edit',   vBuffer)   then
        begin
            PInteger(lParam)^   :=   hwnd;
            Result   :=   False;
        end   else   Result   :=   True;
    end;//发送字符
    procedure TfrmMain.SendText(s: string);
    var
        I:   Integer;
        vHandle:   THandle;
    begin
        vHandle   :=   WebBrowser1.Handle;
        if   vHandle   =   0   then   Exit;
        EnumChildWindows(vHandle,   @EnumChildProc,   Integer(@vHandle));
        if   vHandle   =   0   then   Exit;
        for   I   :=   1   to   Length(S)   do
            SendMessage(vHandle,   WM_CHAR,   Ord(S[I]),   0);
    end;