11

嗨,我正在使用 Curl 发送一个简单的获取请求,它适用于我必须使用它的所有站点,除了最后一个。当我得到响应时,我得到一个奇怪的未编码错误。这就是我得到的详细信息。

* About to connect() to www.shufersal.co.il port 80 (#0)
*   Trying 212.199.57.42...
* connected
* Connected to www.shufersal.co.il (212.199.57.42) port 80 (#0)
> GET /Pages/Catalog.aspx HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) C
hrome/19.0.1084.52 Safari/536.5
Host: www.shufersal.co.il
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Referer:
Cookie: SMC=; TSeb84b7=6c5fc932ce03e1ab1ca864bae7ec71c8d659417300b51c794fce0178

< HTTP/1.1 200 OK
< Cache-Control: private
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Vary: Accept-Encoding
< SPRequestGuid: 217857fb-493b-4542-a5b4-575023c5767a
< X-SharePointHealthScore: 0
* Added cookie ASP.NET_SessionId="5lwlq2ify1glmxirhndgdm45" for domain www.shufe
rsal.co.il, path /, expire 0
< Set-Cookie: ASP.NET_SessionId=5lwlq2ify1glmxirhndgdm45; path=/; HttpOnly
< X-AspNet-Version: 2.0.50727
< X-UA-Compatible: IE=8
< Date: Tue, 05 Jun 2012 12:58:24 GMT
* Added cookie BIGipServerB2C_Commerce="1533875210.20480.0000" for domain www.sh
ufersal.co.il, path /, expire 0
< Set-Cookie: BIGipServerB2C_Commerce=1533875210.20480.0000; path=/
* Replaced cookie TSeb84b7="6c5fc932ce03e1ab1ca864bae7ec71c8d659417300b51c794fce
0178" for domain www.shufersal.co.il, path /, expire 1338902005
< Set-Cookie: TSeb84b7=6c5fc932ce03e1ab1ca864bae7ec71c8d659417300b51c794fce0178;
 Max-Age=900; Path=/
<
* Error while processing content unencoding: invalid block type
* Failed writing data
* Closing connection #0
PHP Fatal error:  Call to a member function find() on a non-object in C:\wamp\ww
w\adwords\grocery_scraper.php on line 86
PHP Stack trace:
PHP   1. {main}() C:\wamp\www\adwords\grocery_scraper.php:0

Fatal error: Call to a member function find() on a non-object in C:\wamp\www\adw
ords\grocery_scraper.php on line 86

Call Stack:
    0.0011     367424   1. {main}() C:\wamp\www\adwords\grocery_scraper.php:0


c:\wamp\www\adwords>php grocery_scraper.php
* About to connect() to www.shufersal.co.il port 80 (#0)
*   Trying 212.143.91.230...
* connected
* Connected to www.shufersal.co.il (212.143.91.230) port 80 (#0)
> GET /Pages/Catalog.aspx HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) C
hrome/19.0.1084.52 Safari/536.5
Host: www.shufersal.co.il
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Referer:

< HTTP/1.1 200 OK
< Cache-Control: private
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=utf-8
< Content-Encoding: gzip
< Vary: Accept-Encoding
< SPRequestGuid: 8adff954-20d7-4d0a-9cab-193bc6cd6e72
< X-SharePointHealthScore: 0
< X-AspNet-Version: 2.0.50727
* Added cookie ASP.NET_SessionId="ji00xpqq5z1ufa454t1c0c45" for domain www.shufe
rsal.co.il, path /, expire 0
< Set-Cookie: ASP.NET_SessionId=ji00xpqq5z1ufa454t1c0c45; path=/; HttpOnly
* Added cookie SMC="" for domain www.shufersal.co.il, path /, expire 1370437143
< Set-Cookie: SMC=; expires=Wed, 05-Jun-2013 12:59:03 GMT; path=/; HttpOnly
< X-UA-Compatible: IE=8
< Date: Tue, 05 Jun 2012 12:59:02 GMT
* Added cookie BIGipServerB2C_Commerce="1533875210.20480.0000" for domain www.sh
ufersal.co.il, path /, expire 0
< Set-Cookie: BIGipServerB2C_Commerce=1533875210.20480.0000; path=/
* Added cookie TSeb84b7="c054d61ec8ab44efb7ca8f8680023cf1889b86d8962f57f14fce029
7" for domain www.shufersal.co.il, path /, expire 1338902044
< Set-Cookie: TSeb84b7=c054d61ec8ab44efb7ca8f8680023cf1889b86d8962f57f14fce0297;
 Max-Age=900; Path=/
<
* Error while processing content unencoding: invalid stored block lengths
* Failed writing data
* Closing connection #0

任何想法出了什么问题?或如何解决?也许有一个参数可以跳过 unencoding 之类的并在 php.ini 上执行。

4

1 回答 1

6

错误消息Error while processing content unencoding来自 libcurl,表示它在 gzip 流中检测到问题,导致无法解压缩完整内容。

这表明站点或 zlib/curl 中存在问题,但我宁愿怀疑该站点...

作为一种解决方法,尝试在不压缩的情况下请求页面。

于 2017-10-13T09:46:59.840 回答