用IDHttp组件Post数据之后,怎么知道结果是成功的?

milunhailili 2009-07-11 01:00:27
比如我想登录校内网www.xiaonei.com
代码如下:
var
ts: TStringStream;
S: string;
begin
IdHTTP1.HandleRedirects := True;
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
ts := TStringStream.Create('email=85580499@qq.com&password=ser&origURL=http%3A%2F%2Fwww.xiaonei.com%2FSysHome.do&formName=&method=&submit=%E7%99%BB%E5%BD%95'); //此数据是用HttpWatch Pro获取的,应该是没错的.
try
IdHTTP1.Request.Referer := 'http://login.xiaonei.com/Login.do';
S := IdHTTP1.Post('http://login.xiaonei.com/Login.do', ts);
//其它处理.....
finally
ts.Free;
end;
end;
...全文
91 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
haitao 2009-07-12
  • 打赏
  • 举报
回复
根据它指明的编码方式,自己转一下码,一般的乱码就是utf-8,delphi有函数可以转的
milunhailili 2009-07-12
  • 打赏
  • 举报
回复
S里面的中文都是乱码.是编码的总问题吧.谁知道需要怎么转换一下?
milunhailili 2009-07-12
  • 打赏
  • 举报
回复
呵,只有这种方法吗,还有没有更好的方法呢.
shaoyiping 2009-07-11
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 pathletboy 的回复:]
返回的html内容不是在S里嘛,根据返回内容进行判断处理啊。
[/Quote]

For Example
if pos('登陆成功,欢迎你回来',s)>0 then
showmessage('Login Success!')
pathletboy 2009-07-11
  • 打赏
  • 举报
回复
返回的html内容不是在S里嘛,根据返回内容进行判断处理啊。
dinoalex 2009-07-11
  • 打赏
  • 举报
回复
try
IdHTTP1.Post(LoginUrl,LoginInfo,Response);
except
showmessage('登陆失败');
end;

5,388

社区成员

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

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