我写了一个bash脚本,从网站使用curl获取输出,并在html输出上做了一堆字符串操作。问题是当我运行它的一个网站,它返回其输出gzipped。在浏览器中访问网站工作正常。
@H_502_27@当我手动运行curl,我得到gzipped输出:
$ curl "http://example.com"
以下是该网站的标题:
HTTP/1.1 200 OK Server: Nginx Content-Type: text/html; charset=utf-8 X-Powered-By: PHP/5.2.17 Last-Modified: Sat,03 Dec 2011 00:07:57 GMT ETag: "6c38e1154f32dbd9ba211db8ad189b27" Expires: Sun,19 Nov 1978 05:00:00 GMT Cache-Control: must-revalidate Content-Encoding: gzip Content-Length: 7796 Date: Sat,03 Dec 2011 00:46:22 GMT X-Varnish: 1509870407 1509810501 Age: 504 Via: 1.1 varnish Connection: keep-alive X-Cache-Svr: p2137050.pubip.peer1.net X-Cache: HIT X-Cache-Hits: 425
我知道返回的数据是gzipped,因为这返回html,如预期:
$ curl "http://example.com" | gunzip
我不想管道输出通过gunzip,因为脚本工作原样在其他网站,通过gzip管道会破坏那个功能。
我试过的
>更改user-agent(我尝试过浏览器发送的同一个字符串,“Mozilla / 4.0”等)
>男人卷曲
> google search
>搜索stackoverflow
一切都来了空
有任何想法吗?