LWP でベーシック認証に対応する


LWP で ベーシック認証のかかったページにアクセスするには、authorization_basic を使えば良いらしい。簡単だ。

use strict;
use LWP::UserAgent;
use HTTP::Request;

my $req = HTTP::Request->new(GET => "https://foo.bar.com/basic/auth.html"); $req->authorization_basic('account', 'password'); my $ua = LWP::UserAgent->new(); my $res = $ua->request($req);
if ($res->is_success) { print $res->content; } else { print $res->code; }

станция техобслуживания at 2014年3月31日 02:07

I'm extremely impressed along with your writing abilities as neatly as with the format on your weblog. Is that this a paid topic or did you modify it your self? Either way keep up the nice high quality writing, it's uncommon to look a nice weblog like this one today..