我想编写一个脚本来登录到Web应用程序,然后移动到其他地区的应用程序的 :如何使用Perl的LWP登录到Web应用程序?
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
use Data::Dumper;
$ua = LWP::UserAgent->new(keep_alive=>1);
my $req = POST "http://example.com:5002/index.php",
[ user_name => 'username',
user_password => "password",
module => 'Users',
action => 'Authenticate',
return_module => 'Users',
return_action => 'Login',
];
my $res = $ua->request($req);
print Dumper(\$res);
if ($res->is_success) {
print $res->as_string;
}
当我尝试这个代码,我无法登录到该应用程序。返回的HTTP状态代码是302找到的,但没有数据。
如果我发布用户名/密码与所有必需的东西,那么它应该返回应用程序的主页,并保持连接生活,以移动应用程序的其他部分。