吐き出してるRSSを取得するのにPHPにてfile()関数を使って取得してたけどどうも取得できないサイトがある.いろいろ調べたら
[Request Header] Accept-Encoding: gzip,deflate [Response Header] Content-Encoding: gzip
そこでfsockopen()関数を使用してリクエストヘッダーにてContent-Encodingを渡さないようにした.
$req_message = "GET /index.html HTTP/1.1 ";
$req_message .= "HOST: graffiti-web.org\r\n";
$req_message .= "\r\n";
fsockopen('graffiti-web.org', 80, $errno, $errstr, 5);
fputs($handle, $req_message);
socket_set_timeout($handle, 5);
$response = '';
while(!feof($handle)) {
$response .= fgets($handle, 4096);
}
header('Content-type: text/plain');
print $response;
fclose ($handle);
これってPHPの設定かなんかでfile()関数でもできるのかな?
Apacheのモジュールとかで転送量を減らす為のmod_gzipってやつです。PHPにもあったかな?
PEARにRSS取るのなかったかなぁ。
Content-Encodingみてgzipだったら解凍して...ってのがスマートかもねー。
contributor wafuwafu : 2007年04月24日 17:19
> wafuwafu さん
どーも。
いくつかpearにそれ系のライブラリはありますね。
contributor nao : 2007年04月24日 17:36