function Tform1.IdHttpInit;
begin
idhtp1.AllowCookies:=True;
idhtp1.HTTPOptions:=[hoForceEncodeParams];
idhtp1.ProtocolVersion:=pv1_1;
idhtp1.Request.ContentType:='Content-Type=application/x-www-form-urlencoded; charset=UTF-8';
idhtp1.Request.CacheControl:='no-cache';
idhtp1.Request.UserAgent:='User-Agent=Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)';
idhtp1.Request.Accept:='Accept=*/*';
idhtp1.Request.AcceptEncoding:='Accept-Encoding=gzip,deflate';
idhtp1.Request.AcceptCharSet:='Accept-Charset=gb2312,utf-8;q=0.7,*;q=0.7';
idhtp1.Request.Connection:='Connection=keep-alive';
idhtp1.Request.Host:='Host=kyfw.12306.cn';
idhtp1.Request.Referer:='https://kyfw.12306.cn/otn/login/init';
idhtp1.Request.AcceptLanguage:='Accept-Language=zh-cn';
Result:='';
end;
function Tform1.GetCodeImg;
var url:string;
response:TMemoryStream;
jpg:TJPEGImage;
begin
response:=TMemoryStream.Create;
url:='https://kyfw.12306.cn/otn/passcodeNew/getPassCodeNew?module=login&rand=sjrand&0.3110086616057921';
idhtp1.Get(url,response);
jpg:=TJPEGImage.Create;
jpg.LoadFromStream(response);
Result:='';
end;
function Tform1.Login;
var
url : string;
Params:TStrings;
begin
Params:=TStringList.Create;
Params.Add('loginUserDTO.user_name=xxxxxx@qq.com');//用户名
Params.Add('userDTO.password=xxxxxxx');//密码
Params.Add('randCode=ku6a');//验证码
Params.Add('randCode_validate=');
Params.Add('OTcyNTU4=ZjIzYzc3MWJmMDk4OTk5YQ==');
Params.Add('myversion=undefined');
end;