Delphi使用IdHttp 获取 HttpsURL内容

uses IdHTTP, IdSSLOpenSSL;

function HttpsGet(const aURL, aContentFile: string): Boolean;
var
vIdHTTP: TIdHTTP;
vSSL: TIdSSLIOHandlerSocket;
vMemory: TMemoryStream;
begin
try
vIdHTTP :
= TIdHTTP.Create(nil);
vSSL :
= TIdSSLIOHandlerSocket.Create(nil);
vMemory :
= TMemoryStream.Create;
try
vIdHTTP.IOHandler :
= vSSL;
vSSL.SSLOptions.Method :
= sslvSSLv3;
vIdHTTP.Get(aURL, vMemory);
vMemory.SaveToFile(aContentFile);
Result :
= True;
finally
vMemory.Free;
vSSL.Free;
vIdHTTP.Free;
end;
except
Result :
= False;
end;
end;

还需要将http://www.wesoho.com/soft/down/openssl.rar中的文件和EXE放到一起。

你可能感兴趣的:(Delphi)