글쎄, 응답 헤더가 실제로는 file_get_contents
의 데이터 인코딩에 대해 알려주는대로 검사해야합니다.
예를 들어, gzip으로 인코딩 된 경우 압축을 풀어야합니다.
일반적으로 file_get_contents()
은 서버가 압축을 지원하지 않는다는 것을 알기 때문에 요청을 보냅니다.
그러나 일부 서버는 상관 없어 어쨌든 당신에게 압축 된 응답을 보내
<?php
$url = 'http://www.fxp.co.il/';
$buffer = file_get_contents($url);
echo $url, '<hr>', '<pre>', implode("\n", $http_response_header), '</pre>';
$bare = gzdecode($buffer);
echo '<hr>', htmlspecialchars(substr($bare, 0, 256));
출력 :
http://www.fxp.co.il/
------------------------------------------------------------
HTTP/1.1 200 OK
Server: nginx/0.7.67
Date: Mon, 29 Aug 2011 19:19:55 GMT
Content-Type: text/html; charset=UTF-8
Connection: close
Set-Cookie: bb_lastvisit=1314607056; expires=Tue, 28-Aug-2012 19:12:44 GMT; path=/
Set-Cookie: bb_lastactivity=0; expires=Tue, 28-Aug-2012 19:12:44 GMT; path=/
X-Accel-Expires: 600
Cache-control: must-revalidate, post-check=0, pre-check=0
Pragma: cache
Vary: Accept-Encoding,User-Agent
Content-Encoding: gzip
Content-Length: 14170
Expires: Tue, 24 Jan 1984 08:00:00 GMT
X-Header: Boost Citrus 1.9
Cache-Control: must-revalidate, post-check=0, pre-check=0
------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="rtl" lang="he"> <head> <meta http-equiv="Content-Type" content="text/html; charset
받아 치료를!
URL을 난독 화 한 이유가 무엇입니까? – PeeHaa
gzip 된 콘텐츠가 전송되고 있습니까? –
개인 정보 보호를 위해 URL을 난독 처리합니다. 이런. - Google의 콘텐츠도 gzipped - 그리고 그들은 여전히 잘 나타납니다 ... –