Delphi Android使用idhttp.get抓取https(SSL)文件


本文整理自网络,侵删。

 
uses
 IdSSLOpenSSL,idhttp;
function HttpsAuthGet(Url, Username, Password: string):string;
var
  ssl: TIdSSLIOHandlerSocketOpenSSL;
  http: TIdHTTP;
begin
  http := TIdHttp.Create(nil);
  try
    ssl := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
    try
      http.IOHandler := ssl;
      http.Request.BasicAuthentication:=True;
      http.Request.Username := Username;
      http.Request.Password := Password;
      Result:=http.Get(Url);
      if (http.ResponseCode<200) or (http.ResponseCode>=300) then
        raise Exception.Create(http.ResponseText);
    finally
      FreeAndNil(ssl);
    end;
  finally
    FreeAndNil(http);
  end;
end;

相关阅读 >>

Delphi xe将图标和图像添加为资源

Delphi在手机桌面图标上显示数字

Delphi检查网络连接状态3种方式

Delphi驱动方式winio模拟按键

minsperday:一天中有多少分钟

Delphi 如何解析网址?

Delphi在64位系统下读写注册表

Delphi 输入法设置(imemode与imename)

Delphi textfile utf8编码读写

Delphi取ajax网页内容

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...