procedure TForm1.btn1Click(Sender: TObject);
var
Strm:TStringStream;
i:Integer;
begin
Strm := TStringStream.Create('');
idhtp1.Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'; //关键;
//针对Idhttp的Cookies管理来说,这句是必需的。网上有人会问:“为什么CookieManager.CookieCollection.Count个数等于0呢?”;其实关键就在这里了。大家可以测试。
idhtp1.Get('http://www.sogou.com',Strm); //如果这里换成为'www.baidu.com';而不设置UserAgent值的话,就会弹出错误提示框。
ShowMessage(idhtp1.Response.RawHeaders.Text);
i := idhtp1.CookieManager.CookieCollection.Count;
ShowMessage(IntToStr(i));
idhtp1.Disconnect;
idhtp1.Free;
Strm.Free;
end;
// 还有太多的东西要学了~,感觉怎么学也学不完啊。。。养成一个习惯就好。就像大部份网民一样,打开电脑第一件事就是打开QQ。时间长了,不自觉地打开了Delphi~