[分享] HTTP BASIC AUTH with WWW::Mechanize

看板Perl作者 (愚人)時間17年前 (2007/12/10 12:51), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
呵, 公司的 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
文章代碼(AID): #17NCNeNu (Perl)
文章代碼(AID): #17NCNeNu (Perl)