小编sta*_*guy的帖子

如何使用curl解码"Content-Encoding:gzip,gzip"?

我正在尝试使用以下代码使用CURL对网页www.dealstan.com进行解码:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // Define target site
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Return page in string
curl_setopt($cr, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.3 Safari/533.2');
curl_setopt($ch, CURLOPT_ENCODING , "gzip");     
curl_setopt($ch, CURLOPT_TIMEOUT,5); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // Follow redirects

$return = curl_exec($ch); 
$info = curl_getinfo($ch); 
curl_close($ch); 

$html = str_get_html("$return");
echo $html;
Run Code Online (Sandbox Code Playgroud)

但是,它显示了一些垃圾字符

" } {w 6 9 X n .........."约100行.

我试图在hurl.it中找到响应,发现一个有趣的点,看起来html被编码两次(只是猜测,基于响应)

请在下面找到答案:获取http://www.dealstan.com/

200 OK 18.87 kB 490 ms查看请求查看响应HEADERS

Cache-Control:max-age = 0,no-cache

Cf-Ray:18be7f54f8d80f1b-IAD …

html php curl gzip nginx

9
推荐指数
1
解决办法
1万
查看次数

两个自定义帖子类型共享同一类别

是否可以为多个自定义帖子类型添加相同的类别?

例如,

优惠券发布类型 - 交易发布类型 - 两者应该共享共同的类别,例如健康、旅行等。

但是,当我们创建新的帖子类型时,看起来我们还需要提供自定义类别。

您知道如何在没有自定义类别的情况下创建自定义帖子类型吗?

wordpress

6
推荐指数
1
解决办法
5756
查看次数

标签 统计

curl ×1

gzip ×1

html ×1

nginx ×1

php ×1

wordpress ×1