|
帮忙看看这个代码(利用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;
|
|