delphi 登陆网页问题
begin
PostDataStream := TStringStream.Create('');
postList := TStringList.Create;
postList.Add('&loginsubmit=1');
postList.Add('&cookietime=315360000');
postList.Add('&formhash=4cd69240');
postList.Add('&username=' + Edit1.Text + '&password=' + Edit2.Text);
URL := 'http://192.168.1.151:82/do.php?ac=5e88d16502799f5a6ea64cdc58a84dc7&&ref';
try
IdHTTP1.HandleRedirects := true;
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.Referer := URL;
IdHTTP1.Request.AcceptLanguage := 'zh-cn';
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Post(URL, postList, PostDataStream);
except
IdHTTP1.Disconnect;
end;
showmessage(IdHTTP1.Response.RawHeaders.Text);
end;
这个就是我的登陆代码,目前登陆成功,我想实现类似ShellExecute那样调用浏览器打开登陆成功后的主页。
有人知道怎么做吗?
PostDataStream.datastring.返回的是脚本windows.location...
[解决办法]
一般都是 http://www.xx.com?username=123&password=321 这个样子登陆到网页中。
你可以用 idhttp 连接网站,这时候网站返回一个 Key, 再用这个 Key 做为参数 get 网页
这样安全性没问题,也没那么复杂。
[解决办法]
举个例子:
1.login.asp
2.login.htm
2.show.asp
如果用户直接访问show.asp,比较简单的做法是,
show.asp里面查cookie中的用户名及密码等信息是否正确,如果正确,显示相应内容
如果不正确或没cookie,重定向到login.htm
login.htm表单,让用户输入用户名及密码等信息,post给login.asp
login.asp提取表单数据,验证用户名及密码,如果正确,创建或修改cookie记录用户名及密码,重新跳转到show.asp