作者qrtt1 (愚人)
看板Perl
标题[分享] HTTP BASIC AUTH with WWW::Mechanize
时间Mon Dec 10 12:51:51 2007
呵, 公司的 ap 不太听话
常会透逗需要人重开, 觉得每次都要开 brwoser 太麻烦了
可以写个 perl 来做这件事, 第一个问题就是要通过 HTTP BASIC AUTH
上网找了一下范例, 拼凑成下面的 code, 希望对大家也有帮助
====================================================
use WWW::Mechanize;
@info = (
'foo.domain.com:port',
'realm-name',
'user id' => 'password');
my $agent = WWW::Mechanize->new();
$agent->credentials(@info) if @info == 4 or die("information is not enough");
$response = $agent->get(
'
http://foo.domain.com:port/misc.html'
);
print $response->content;
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.128.219.202