使用了IDHTTP,用POST提交数据
var //取Cookie
strMsg:string;
sParams: TStringStream; //用来保存文本
begin
sParams := TStringStream.create(''); //文本为空
IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded'; //请求
try
sParams.WriteString('参数1=结果&参数2=结果2') ; //填冲文本
strMsg:=IdHTTP1.post('http://www.bkhack.com /add-c.asp',sParams) ; //向网址发
memo1.Text:=strmsg; // memo1显示结果
finally
sParams.Free ; //结束
end;
s := 'http://aaa.net/bbs/index.php'; //网址
if CanGetIECookie(s, str) then
begin
CookieStr := 'Cookie: ' + str;
idHttp1.Request.CustomHeaders.Text := CookieStr;
end else
begin
ShowMessage('没有发现本地Cookie,请从Web页面登陆一次。');
Exit;
end;
s := 'http://www.topjishu.com/forum.php';
PostData := TStringList.Create;
PostData.Add('fid=1');
Memo1.Lines.Text := idHTTP1.Post(s, PostData);
PostData.Free;
//提交用户密码
var
S:TStringList;
begin
S := TStringList.Create;
S.Add('user=', edtUser.text);
S.Add('pass=', edtPass.text);
try
HTTP.Post('http://www.bkhack.com/', S);
finally
HTTP.Free;
end;
end;
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。