用 IDHTTP 控件实现登陆论坛的 问题 ( 积分: 200 )

G

gray110

Unregistered / Unconfirmed
GUEST, unregistred user!
D7 + INDY 9 不知道为什么返回的页面仍然是登陆页面
下面是我写的一个过程,不知道sid有什么用,抓包的时候看见COOKIE里有这个
跪求登陆的方法,在线等~~~

var
params : tstringlist;
url,html,sid : string;
**** : tstringstream;
ipos : integer;
begin
**** := tstringstream.Create('');
idhttp1.get('http://www.8da.cc/logging.php?action=login',****);
ipos := pos('sid=',****.DataString);
if ipos >0 then
sid := copy(****.DataString,ipos+4,6);
showmessage(sid);

params := tstringlist.Create;
Params.Add('formhash='+'37c253f4');
Params.Add('referer='+'index.php');
Params.Add('loginmode='+'normal');
Params.Add('referer='+'index.php');
Params.Add('styleid='+'1');
Params.Add('questionid='+'0');
Params.Add('username='+'woshiaqiang');
Params.Add('password='+'820104');
Params.Add('cookietime='+'86400');
Params.Add('answer='+'');
idhttp1.ProtocolVersion := pv1_1;
IdHTTP1.Request.Referer:='http://www.8da.cc/logging.php?action=login';
IdHTTP1.Request.Accept :='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
IdHTTP1.Request.AcceptLanguage := 'zh-cn';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.AcceptEncoding := 'gzip, deflate';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
IdHTTP1.Request.Host := 'www.8da.cc';
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Request.CacheControl := 'no-cache';
showmessage(params.Text);
params.SaveToFile('e:/a.txt');
url := 'http://www.8da.cc/logging.php?action=login' ;
try
html := idhttp1.Post(url,params);
except
showmessage('error');
exit;
end;
memo1.Text := html;
end;
 
D7 + INDY 9 不知道为什么返回的页面仍然是登陆页面
下面是我写的一个过程,不知道sid有什么用,抓包的时候看见COOKIE里有这个
跪求登陆的方法,在线等~~~

var
params : tstringlist;
url,html,sid : string;
**** : tstringstream;
ipos : integer;
begin
**** := tstringstream.Create('');
idhttp1.get('http://www.8da.cc/logging.php?action=login',****);
ipos := pos('sid=',****.DataString);
if ipos >0 then
sid := copy(****.DataString,ipos+4,6);
showmessage(sid);

params := tstringlist.Create;
Params.Add('formhash='+'37c253f4');
Params.Add('referer='+'index.php');
Params.Add('loginmode='+'normal');
Params.Add('referer='+'index.php');
Params.Add('styleid='+'1');
Params.Add('questionid='+'0');
Params.Add('username='+'woshiaqiang');
Params.Add('password='+'820104');
Params.Add('cookietime='+'86400');
Params.Add('answer='+'');
idhttp1.ProtocolVersion := pv1_1;
IdHTTP1.Request.Referer:='http://www.8da.cc/logging.php?action=login';
IdHTTP1.Request.Accept :='image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
IdHTTP1.Request.AcceptLanguage := 'zh-cn';
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
IdHTTP1.Request.AcceptEncoding := 'gzip, deflate';
IdHTTP1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)';
IdHTTP1.Request.Host := 'www.8da.cc';
IdHTTP1.Request.Connection := 'Keep-Alive';
IdHTTP1.Request.CacheControl := 'no-cache';
showmessage(params.Text);
params.SaveToFile('e:/a.txt');
url := 'http://www.8da.cc/logging.php?action=login' ;
try
html := idhttp1.Post(url,params);
except
showmessage('error');
exit;
end;
memo1.Text := html;
end;
 
顶部