请求GZIP的页面并使用cURL和PHP处理 [英] Requesting a GZIP'ed page and processing with cURL and PHP
本文介绍了请求GZIP的页面并使用cURL和PHP处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想发出一个接受gzip网页的cURL请求.然后,我想解压缩页面并对其进行处理.我还没有找到任何现成的示例,因此我想举一个快速的例子.需要调整,发出实际请求并解压缩内容的任何设置.
I'd like to make a cURL request that accepts a gzip'ed page. I would then like to unzip the page and process it. I haven't been able to find any ready built examples, so I would like a quick one. Any settings that need to be adjusted, making the actual request, and decompressing the contents.
推荐答案
You can request a gzipped encoding with curl_setopt, like this:
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
然后您可以使用 gzdecode 解压缩内容,如下所示:
You can then decompress the content with gzdecode like this:
$response = gzdecode($response);
这篇关于请求GZIP的页面并使用cURL和PHP处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文