或者使用requests_redirectable这个option

use LWP;
my $ua = LWP::UserAgent->new(requests_redirectable=>[]);
print $ua->head("http://www.google.cn";)->as_string;


在 2010年5月14日 下午3:11,宇捷 <[email protected]>写道:

>  另外,你得确认跳转是通过后台还是前台方式进行的,js跳转的话,不会得到302,只会是200
>
>
>
> *发件人:* 
> [email protected]<perlchina%[email protected]>[mailto:
> [email protected]<perlchina%[email protected]>]
> *代表 *Hejicheng
> *发送时间:* 2010年5月14日 14:31
> *收件人:* [email protected]
> *主题:* [PerlChina] 一个关于perl获取http code的问题
>
>
>
> 我想得到一个url的http code,调用lwp包中的getprint 和getstore方法,返回的code不准
>
> 如:
> print getstore("http://www.google.cn","123.txt";);
>
> 这是一个跳转页面,期望的结果应该是302,可是实际返回的是200。
>
> 请问有没有其他包,其他方法能返回正确的值
>
>
>
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 
> [email protected]<perlchina%[email protected]>
> 。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 
> [email protected]<perlchina%[email protected]>
> 。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复