为什么用idhttp登陆淘宝网站,都是返回首页,登陆不了?

life923 2008-12-25 11:14:30
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;
...全文
600 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
blueflag 2009-01-06
  • 打赏
  • 举报
回复
自己硬性设定~
或者获取跳转链接,然后get~
life923 2008-12-27
  • 打赏
  • 举报
回复
在java中的话,要第二次请求才能登陆成功,

因为第一次post的时候,淘宝会返回转向另一个页面HTTP/1.1 302 Moved Temporarily,
这个时候要获取转向的页面地址,发送GET 这个页面的地址,才能登陆成功.


我不知道 delphi 怎样去获得这个转向的地址?
life923 2008-12-27
  • 打赏
  • 举报
回复
我说错了 是返回到登陆页,

密码是没有错的,因为我用java的话 也是一样的原始密码,一样的参数,是 可以登陆的
halfdream 2008-12-27
  • 打赏
  • 举报
回复
看起来你代码没什么问题的,返回页面信息你没有仔细看,不是首页.
而是输入密码错误后跳到的登录页.

是的,我判断你问题就在密码这儿。你打开淘宝网页看看源码,它输入密码的地方,应该是使用了一个安全控件。
这样它在HTTP POST时候,密码参数TPL_password应该不是原始的密码串了。
easemaster2008 2008-12-26
  • 打赏
  • 举报
回复
关注!

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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