2009-02-07 44 views

回答

9

可以使用LWP的head()方法在下列方式

use LWP::UserAgent; 
$ua = LWP::UserAgent->new; 
$ua->head('<url>'); 
+0

幸運的是我從機械繼承UserAgent :) – Geo 2009-02-07 14:03:29

3

這裏有一個完整的例子:

use LWP::UserAgent; 

$ua = LWP::UserAgent->new; 
my $response = $ua->head('http://www.perl.com'); 

my $type = $response->content_type; 

print "The type is $type\n"; 

一些服務器嗆HEAD請求,所以當我這樣做,得到的錯誤任何類型,我重試與GET請求,只請求頭幾百字節的資源。

相關問題