$headers = array(
//"Content-type:application/json;charset='utf-8'",
"Cache-Control:no-cache",
"Pragma:no-cache",
//"accept-charset:utf-8",
"Accept-Encoding:gzip",
"User-Agent:Dalvik/2.1.0 (Linux; U; Android 5.1.1;Build/LMY47V)",
"Host:www.domain.cn",
//'Transfer-Encoding:chunked', 压缩不能用这项
//"Content-Type:application/x-www-form-urlencoded",
//"Connection:Keep-Alive",
); /*
* 可写文件
$sourceFile="tmp.txt";
$fp = fopen($sourceFile, "w");
*/ $curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip'); //curl解压gzip页面内容
curl_setopt($curl, CURLOPT_FORBID_REUSE, true);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($curl, CURLOPT_HTTPGET, true);
//curl_setopt($curl, CURLOPT_FILE, $fp);
$data = curl_exec($curl);
curl_close($curl); //file_put_contents('tmpdata.txt',$data);
echo bin2hex($data); //可查看下16进制
$ret = gzuncompress($data); print_r(json_decode($ret,true)

curl解压gzip页面gzcompress内容的更多相关文章

  1. 解压gzip格式文件(包括网页)

    先上源码 参数说名: - source :gzip格式流内容. - len: gzip流长度 - dest: 解压后字符流指针 - gzip: 压缩标志,非0时解压gzip格式,否则按照zip解压 说 ...

  2. 【java】 java 解压tar.gz读取内容

    package com.xwolf.stat.util; import com.alibaba.druid.util.StringUtils; import com.alibaba.fastjson. ...

  3. UWP 解压 GZIP

    准备工作: 通过 NUGET 安装 Microsoft.Bcl.Compression ; 使用命名空间 using System.IO.Compression ; public static asy ...

  4. HttpWebResponse 解压gzip、deflate压缩

    需要使用到两个Stream的子类:GZipStream.DeflateStream,代码如下: public string GetResponseBody(HttpWebResponse respon ...

  5. C# 解压gzip文件(.tgz)

    1.引用 SharpCompress.dll 2.代码 using System;using System.IO;using System.Text;using SharpCompress.Reade ...

  6. HttpClient与APS.NET Web API:请求内容的压缩与解压

    首先说明一下,这里的压缩与解压不是通常所说的http compression——那是响应内容在服务端压缩.在客户端解压,而这里是请求内容在客户端压缩.在服务端解压. 对于响应内容的压缩,一般Web服务 ...

  7. Linux学习之CentOS(十九)------linux 下压缩与解压之 tar、gzip、bzip2、zip、rar

    将文件存储到归档文件中或者从归档文件中获取原始文件,以及为文件创建归档文件 tar [option] [modifiers] [file-list] 参数 file-list是tar进行归档和提取的文 ...

  8. 压缩及解压命令gzip、bzip2、tar

    1. gzip 描述:压缩与解压缩 用法:gzip[选项]...[文件名称]... 选项:-d 解压 gzip hello.txt     # 文件压缩后名为hello.txt.gz gzip -d ...

  9. *.tar 用 tar –xvf 解压 *.gz 用 gzip -d或者gunzip 解压 *.tar.gz和*.tgz 用 tar –xzf 解压 *.bz2 用 bzip2 -d或者用bunzip2 解压 、*.tar.bz2用tar –xjf 解压

    解压: 1.*.tar 用 tar –xvf 解压, --skip-old-files跳过已经存在的文件,压缩用tar -cvf 2.*.bz2 用 bzip2 -d或者用bunzip2 解压 3.* ...

随机推荐

  1. 内核中container_of宏的详细分析【转】

    转自:http://blog.chinaunix.net/uid-30254565-id-5637597.html 内核中container_of宏的详细分析 16年2月28日09:00:37 内核中 ...

  2. linux新内核的freeze框架以及意义【转】

    转自:https://blog.csdn.net/dog250/article/details/5303442 linux的电源管理发展非常迅速,比如在挂起到内存的时候,系统会冻结住所有的进程,也就是 ...

  3. 连接Linux服务器操作Oracle数据库

    连接Linux服务器操作Oracle数据库   由于项目已经上线,现场的数据库服务器不允许直接用Oracle的客户端plsqldev.exe来连接,只能通过Linux服务器的命令来操作. 以下是用Se ...

  4. crontab定时作业

    crontab用于在指定时间执行某项作业,如执行脚本或命令. 1.crontab -e      创建一个crontab文件,并添加作业(这个crontab的拥有者是创建者). 这里要注意:必须指定s ...

  5. 003_Linux的Cgroup<实例详解>

    为什么要有cgroup Linux系统中经常有个需求就是希望能限制某个或者某些进程的分配资源.也就是能完成一组容器的概念,在这个容器中,有分配好的特定比例的cpu时间,IO时间,可用内存大小等.于是就 ...

  6. saltstack自动化运维系列⑤之saltstack的配置管理详解

    saltstack自动化运维系列⑤之saltstack的配置管理详解 配置管理初始化: a.服务端配置vim /etc/salt/master file_roots: base: - /srv/sal ...

  7. vue2进阶之v-model在组件上的使用

    v-model 用在 input 元素上时 v-model虽然很像使用了双向数据绑定的 Angular 的 ng-model,但是 Vue 是单项数据流,v-model 只是语法糖而已: <in ...

  8. php计算给定时间之前的函数

    这里给定一个时间,计算这个时间在多久前,比如:2天前,1年前 function prettyDate($date){ $time = strtotime($date); $now = time(); ...

  9. pytest三:fixture_conftest.py 自定义测试用例的预置条件(setup)

    用例加 setup 和 teardown 可以实现在测试用例之前或之后加入一些操作,但返种是整个脚本全局生效的,如果我想实现以下场景:用例 1 需要先登录,用例 2 不需要登录,用例 3 需要先登录. ...

  10. 关于ie7下display:inline-block;不支持的解决方案。

    摘要: 声明:此文章为转载(点击查看原文),如有侵权24小时内删除.联系QQ:1522025433. 今天码的时候遇到这个问题了. 如果本身是内联元素的,把它的display属性设置设置为inline ...