delphi HttpGet 判断链接是否可以访问


本文整理自网络,侵删。

 
function HttpGet(idhttp:tidhttp;url,cookies:widestring;var html:string):boolean;
begin
  result:=true;
  try
    idhttp.Disconnect;
  except
  end;
  idhttp.HandleRedirects:=true;
  idhttp.AllowCookies:=false;
  idhttp.HTTPOptions:=[hoForceEncodeParams];
  idhttp.OnStatus:=frm_work.HttpStatus;
  idhttp.OnWork:=frm_work.HttpWork;
  idhttp.OnWorkBegin:=frm_work.HttpWorkBegin;
  idhttp.OnDisconnected:=frm_work.HttpDisconnected;
  idhttp.Port:=80;
  idhttp.ReadTimeout:=1000*c_timeout;

  idhttp.Request.UserAgent:=DataBase.userAgent;
  idhttp.Request.Referer:=url;
  idhttp.Request.CustomHeaders.Clear;
  idhttp.Request.CustomHeaders.Append(cookies);

  httpproxyinit(idhttp);
  try

    if stopaction(orderstop) then
      begin
        result:=false;
        exit;
      end;    
    timeoutstart;
    try
      html:=idhttp.get(EnURLstr(url));
    except
      html:='';
      result:=false;
    end;
  finally     
    idhttp.Disconnect;
    timeoutend;
  end;
  
end;

相关阅读 >>

Delphi 如何判断某一窗口最大化

Delphi edit 让密码变成点

Delphi在memo按键实现全选

Delphi禁止用户切换任务

Delphi 文件,文件夹删除移动和拷贝

Delphi 判断按键状态

Delphi 把流中的字符串转换为 utf 格式

Delphi dbgrid鼠标滚屏

Delphi firedac 的recordcount 相关测试 记录

Delphi 判断字符串是否为纯数字组合

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



打赏

取消

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

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

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

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

评论

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