呵呵,终于做出来了,有一定收获,
在算法上还是花了不少时间,
以前解gzip内容,现在是deflate,少了文件头内容,所以
用以前思路老是碰到"data error"问题。
用的是zLib控件:
(http://www.2ccc.com/article.asp?articleid=4269)
下面是可以运行的代码片断:
uses ZLibEx;
procedure TForm1.Button3Click(Sender: TObject,',',');
var
url: string;
IdHTTP: TIdHTTP;
stream, out_stream: TMemoryStream;
begin
url := 'http://bill.finance.sina.com.cn/bill/trade_item.php?stock_code=sh580013&pages=0&time=1218809515';
IdHTTP := TIdHTTP.Create(nil,',',');
stream := TMemoryStream.Create;
out_stream := TMemoryStream.Create;
try
IdHTTP.get(url, stream,',',');
stream.Position:=0;
ZLibEx.ZDecompressStream2(stream, out_stream, -15,',',');
stream.SaveToFile('c:\1.txt',',',');
out_stream.SaveToFile('c:\2.txt',',','); //这个就是我们要的html内容
finally
stream.Free;
out_stream.Free;
IdHTTP.Free;
end;
end;
关键字词: