关于curl header gzip 的读取
当用curl取有些压缩网站的时候 又想取到头部
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$ch = curl_init();curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");curl_setopt($ch, CURLOPT_HEADER, 1);$content=curl_exec($ch);curl_close($ch);
取回来的内容是:
http/1.1 200 ok
date: fri, 12 aug 2011 07:07:59 gmt
server: apache
set-cookie: phpsessid=ekda6bsph83mltvna208belhj5; path=/
expires: fri, 12 aug 2011 07:07:59 gmt
cache-control: no-store, no-cache, must-revalidate
pragma: no-cache
last-modified: fri, 12 aug 2011 07:07:59 gmt
content-encoding: gzip
vary: accept-encoding
content-length: 2547
keep-alive: timeout=300
connection: keep-alive
content-type: text/html; charset=gb2312
秒df胍yc余嬸革x栠wm'$~0p;~馦m?趹g趋雄巺?0捈鐃?憿腤v㏕`??c爗笍?ojt慧vcb?再c書鏗鄕b丆?杘f]衆?f?f肸b...
其实是头部+压缩内容,问题是我怎么才能读取压缩的内容呢,即网站返回的内容。
如果不要头部即去掉 直接curl_setopt($ch, curlopt_header, 1);
把取回来的内容保存到file.gz 文件就可以打开。
急啊,就剩最后20分了,谢谢回答啊。
------解决方案--------------------
要不把二进制数据用gzdecode函数解压吧。










