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;

你可能感兴趣的:(DELPHI)