perl LWP::UserAgent

#!/usr/bin/perl

use LWP::UserAgent;
#use HTTP::Request;
my $login_url = 'https://domain/login';
my $ua = new LWP::UserAgent;
#my $req = new HTTP::Request GET=> $login_url;
$ua->cookie_jar({file=>"./cookies.txt"});

my %login_form = (
        'ID1'=>'123',  #post请求需要的参数
        'ID2'=>'123'
);
my $res = $ua -> get($login_url);
if ( $res->is_success ) {
}

my $hres = $ua->post( $login_url, \%login_form);
$res = $ua->get("https://$login_url/jobs");  #登录后继续访问
print Dumper($hres);
print Dumper($res);
print $res->content;

你可能感兴趣的:(perl)