Lazarus中文社区

 找回密码
 立即注册(注册审核可向QQ群索取)

QQ登录

只需一步,快速开始

Lazarus IDE and 组件 下载地址版权申明
查看: 1885|回复: 3

帮忙看看这个代码(fphttpclient获取验证码图片)

[复制链接]

该用户从未签到

发表于 2020-8-18 17:06:36 | 显示全部楼层 |阅读模式
帮忙看看这个代码(利用fphttpclient 的get获取验证码图片),第一次成功,第二次就不成功了!网站返回数据:Forbidden, Please turn off CC
但是用浏览器页面连续刷新就不会出现这样的问题!郁闷。。。

uses fphttpclient

procedure TForm1.Button1Click(Sender: TObject);
var
  Client: TFPHTTPClient;
  url:string;
  response:TStream;
  png:TPortableNetworkGraphic;
begin
  Client := TFPHTTPClient.Create(nil);
  url:='http://bbs.eyuyan.com/ck.php?nowtime=1';
  response:=TMemoryStream.Create();
  png:=TPortableNetworkGraphic.Create;
  try
    Client.AllowRedirect := True;
    Client.AddHeader('Accept','*/*');
    Client.AddHeader('Content-Type','application/x-www-form-urlencoded');
    Client.AddHeader('User-Agent','Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)');
    Client.AddHeader('Cache-Control','no-cache');
    Client.Get(url,response);
    response.position:=0;
    png.LoadFromStream(response);
    Image1.Picture.Assign(png);
  finally
    Client.Free;
  end;
end;

回复

使用道具 举报

*滑块验证:

本版积分规则

QQ|手机版|小黑屋|Lazarus中国|Lazarus中文社区 ( 鄂ICP备16006501号-1 )

GMT+8, 2025-5-2 10:22 , Processed in 0.043984 second(s), 12 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表