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

kantaguai 2010-11-19 10:29:36
请教如何用webbrowser自动登录淘宝,请各位大侠给点思路
...全文
392 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
kantaguai 2010-11-19
  • 打赏
  • 举报
回复
好的,我试试,谢谢
bdmh 2010-11-19
  • 打赏
  • 举报
回复

//枚举组件,这个不是淘宝的,我找到的是'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;
bdmh 2010-11-19
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 kantaguai 的回复:]
2楼的方法我试过了,淘宝的登录有一个专门控件的,试了很多次都不成功!
[/Quote]
这个控件你需要遍历页面组件,然后找到他的句柄,向他发送字符消息
kantaguai 2010-11-19
  • 打赏
  • 举报
回复
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);
lght 2010-11-19
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 kantaguai 的回复:]

2楼的方法我试过了,淘宝的登录有一个专门控件的,试了很多次都不成功!
[/Quote]

用webbrowser发送数据不行吗?这个也能看见网页啊
kye_jufei 2010-11-19
  • 打赏
  • 举报
回复
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.
kantaguai 2010-11-19
  • 打赏
  • 举报
回复
2楼的方法我试过了,淘宝的登录有一个专门控件的,试了很多次都不成功!
kantaguai 2010-11-19
  • 打赏
  • 举报
回复
我想要在webbrowser上自动登录啊,我需要能看到网页的
ywkywk000 2010-11-19
  • 打赏
  • 举报
回复
二楼的方法有道理
kantaguai 2010-11-19
  • 打赏
  • 举报
回复
能具体一点吗,谢谢您的回复
lght 2010-11-19
  • 打赏
  • 举报
回复
1. 抓包看发送的参数,然后用webbrowser发送数据

2. 用webbrowser打开登录页面,给用户名密码框赋值,然后模拟点击按钮
bdmh 2010-11-19
  • 打赏
  • 举报
回复
用idhttp吧,已经搞定,web也可以,就是找到那连个框框,填写好并提交

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧