有玩过LWP+IE Cookie的吗?

有玩过LWP+IE Cookie的吗?

下面这段代码在访问xxx.com时放出IE保存的Cookie, 但是死活都不生效, 不知道什么原因

[Copy to clipboard] [ - ]
CODE:
#!/usr/bin/perl -w
use strict;

use LWP;
use LWP::Debug qw(+);
use HTTP::Cookies::Microsoft;
use Win32::TieRegistry(Delimiter => "/");

LWP::Debug::trace('add_cookie_header()');

my $cookies_dir = $Registry->
    {"CUser/Software/Microsoft/Windows/CurrentVersion/Explorer/Shell Folders/Cookies"};

my $cookie_jar = HTTP::Cookies::Microsoft->new(
                  file     => "\"$cookies_dir\\index.dat\"",
                  'delayload' => 0,
              );
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Foxy/1; .NET CLR 2.0.50727; CIBA)");
$ua->cookie_jar( $cookie_jar );
my $URL = "http://www.xxx.com/forum/index.php";
my $myReq = HTTP::Request->new(GET =>"$URL");
$cookie_jar->add_cookie_header($myReq);
my $myRes = $ua->request($myReq);
print $myRes->content;

下面这段代码改成用FF的Cookie, 正常:

[Copy to clipboard] [ - ]
CODE:
#!/usr/bin/perl -w
use strict;

use LWP;
use LWP::Debug qw(+);
use HTTP::Cookies::Mozilla;

my $cookie_jar = HTTP::Cookies::Mozilla->new(
                  file     => "c:/Documents and Settings/Administrator/Application Data/Mozilla/Firefox/Profiles/98zahcst.
default/cookies.sqlite",
              );
my $ua = LWP::UserAgent->new;
$ua->agent("Firefox/3.0.3");
$ua->cookie_jar( $cookie_jar );
my $URL = "http://www.xxx.com/forum/index.php";
my $myReq = HTTP::Request->new(GET =>"$URL");
$cookie_jar->add_cookie_header($myReq);
#my $myRes = $ua->send_request($myReq);
my $myRes = $ua->request($myReq);
print $myRes->content;

落叶季节,思念季节
我一般都是用 LWP 登录一下就可以了。