php - 使用cURL获取压缩内容 [英] php - Get compressed contents using cURL

查看:206
本文介绍了php - 使用cURL获取压缩内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取各种网页的内容。其中一些是使用不同的方法(gzip,deflate等)压缩。我在互联网上搜索并找到gzip压缩内容的解决方案:

  $ ch = curl_init(http:// games2k 。净/); 
curl_setopt($ ch,CURLOPT_ENCODING,gzip);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
$ output = curl_exec($ ch);
curl_close($ ch);
echo $ output;

但是,这只适用于单个方法。我需要一个解决方案,尽可能多的压缩方法(最好是所有的)或至少最流行的两个是gzip和deflate。



非常感谢

 

$ ch = curl_init(http://games2k.net/);
curl_setopt($ ch,CURLOPT_ENCODING,);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
$ output = curl_exec($ ch);
curl_close($ ch);
echo $ output;

保持引号为空


I need to get content of various web pages. Some of them are compressed using different methods (gzip, deflate, etc). I've searched on the Internet and found the solution for gzipped content:

$ch = curl_init("http://games2k.net/");
curl_setopt($ch,CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$output = curl_exec($ch);
curl_close($ch);
echo $output;

However, this only works for a single method. I need a solution that works for as many compression methods as possible (preferably all of them) or at least the most popular two which are gzip and deflate.

Thanks very much for your help!

解决方案

did you try

$ch = curl_init("http://games2k.net/");
curl_setopt($ch,CURLOPT_ENCODING , "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$output = curl_exec($ch);
curl_close($ch);
echo $output;

keep the quotes empty

这篇关于php - 使用cURL获取压缩内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆