[分享] HTTP BASIC AUTH with WWW::Mechanize
呵, 公司的 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
Perl 近期熱門文章
PTT數位生活區 即時熱門文章