tetsunosukeのnotebook

tetsunosukeのメモです

LWPで外部サーバのコンテンツを取得

http://mixi.jp/view_bbs.pl?id=3827693

LWP::Simple だと HTTP のレスポンスヘッダが取れないとの事なので

まぁ元記事を書いた人が悪いんですが(笑)

確かに以下のように書いてあります。


You will not be able to examine the response code or response headers (like 'Content-Type') when you are accessing the web using this function. If you need that information you should use the full OO interface (see LWP::UserAgent).

が、StatusCodeについてはgetstoreメソッドで取得できます。

例)
$status_code = getstore($url,"/dev/null");
print $status_code;

headメソッドでは

$content_type, $document_length, $modified_time, $expires, $server

の5つを取得できます。