用CURL有一个属性
curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate");
完整代码:
functionget_html($url){ $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch,CURLOPT_HTTPHEADER, array( 'pragma:no-cache', 'cache-control:no-cache', 'sec-ch-ua:"NotA;Brand";v="99","Chromium";v="96","GoogleChrome";v="96"', 'accept:application/json,text/plain,*/*', 'content-type:application/json', 'sec-ch-ua-mobile:?0', 'user-agent:Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/96.0.4664.93Safari/537.36', 'sec-ch-ua-platform:"Windows"', 'sec-fetch-site:same-origin', 'sec-fetch-mode:cors', 'sec-fetch-dest:empty', 'accept-language:zh-CN,zh;q=0.9', )); //Thisiswhatsolvedtheissue(Acceptinggzipencoding) curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate"); $response=curl_exec($ch); curl_close($ch); echo$response; }
原作者:王昊的个人博客
相关推荐
© 2020 asciim码
人生就是一场修行