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放到一起。

posted @ 2011-06-14 15:02  欧阳蓝缺  阅读(4077)  评论(0编辑  收藏  举报