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 unix时间转换成Delphi时间

Delphi实现拖动无标题窗口的5种方法

Delphi stringgrid常用属性和常用操作

Delphi 试试带参数的 exit

Delphi检查是否在64位windows环境中运行?

Delphi 关于使用access中带参数的查询的用法

Delphi firedac操作sqlite内存数据库

Delphi 中判断windows系统是否是64位系统

Delphi idhttp实现get方法下载文件,断点续传

Delphi ttabcontrol

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



打赏

取消

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

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

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

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

评论

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