【问题标题】:PHP cURL getting encoded dataPHP cURL 获取编码数据
【发布时间】:2009-10-24 12:33:02
【问题描述】:

我已经使用 cURL 将页眉和压缩正文下载到一个字符串中,问题是我不知道如何将它们相互拆分以及如何解压缩正文?

谢谢!

【问题讨论】:

    标签: php curl web-crawler


    【解决方案1】:

    在获取页面之前尝试设置CURLOPT_ENCODING cURL 选项,如下所示:

    <?php
    $ch = curl_init("http://www.example.com/");
    // supported encodings: "identity", "deflate", and "gzip"
    // or empty string, "", sending all supported encoding types
    curl_setopt($ch, CURLOPT_ENCODING, "");
    
    curl_exec($ch);
    curl_close($ch);
    

    这应该发送Accept-Encoding 标头并自动解码响应。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-12
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-19
      • 2017-07-14
      • 2014-12-04
      相关资源
      最近更新 更多