本文整理自网络,侵删。
for i:=0 to IdHTTP1.Response.RawHeaders.Count-1 do
begin
if UpperCase(Copy(IdHTTP1.Response.RawHeaders[i],1,10))='SET-COOKIE' then
begin
sCookieTmp:=Trim(Copy(IdHTTP1.Response.RawHeaders[i],12,MAXINT));
sCookieTmp:=Copy(sCookieTmp,1,Pos(';',sCookieTmp)-1);
sCookie:=sCookie+'; '+sCookieTmp;
end;
end;
IdHTTP1:=TIdHTTP.Create(nil);
try
IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; EmbeddedWB 14.52 from: http://www.bsalsa.com/ EmbeddedWB 14.52)';
IdHTTP1.Request.Referer:='';
IdHTTP1.Request.Accept:='*/*';
IdHTTP1.Request.Connection:='Keep-Alive';
IdHTTP1.Request.AcceptLanguage:='zh-cn';
IdHTTP1.ReadTimeout:=30000;
IdHTTP1.Request.CacheControl:='no-cache';
IdHTTP1.Request.ContentType:='text/plain; charset=utf-8';
IdHTTP1.HandleRedirects:=True;
IdHTTP1.HTTPOptions:=IdHTTP1.HTTPOptions+[hoKeepOrigProtocol];
IdHTTP1.ProtocolVersion:=pv1_1;
IdHTTP1.Request.CustomHeaders.Add('X-AjaxPro-Method: xhs');//设置非标准http头信息
IdHTTP1.Request.CustomHeaders.Add('Cookie: '+sCookie);//设置cookie
sPost:=TStringStream.Create('');
try
sPost.WriteString('');
try
sHtml:=IdHTTP1.Post('http://www.xxx.com',sPost);
except
end;
finally
sPost.Free;
end;
finally
IdHTTP1.Free;
end;
相关阅读 >>
Delphi 不管什么datetime日期格式时间格式转换都不会错了
Delphi timagelist 中使用 透明 png 图标
Delphi windows 下用 Delphi 代码杀死进程,或者杀死自己
Delphi intraweb 在iis下发布的web.config
更多相关阅读请进入《Delphi》频道 >>