簡體   English   中英

LWP :: UserAgent和登錄憑據

[英]LWP::UserAgent and login credentials

我正在嘗試使用LWP :: UserAgent設置憑據,但我無法登錄。 $username$passwd是正確的。 我不明白我應該把什么放在3rd argument (根據dos $realm ,這里的Authentication )。 這里的片段:

my $browser = LWP::UserAgent->new(agent => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Firefox/31.2.0',
$browser->credentials("domain.com:80", "Authentication",$username, $passwd);
my $response=$browser->get("http://domain.com/page");

print $response->content;

我更正了領域@ThisSuitIsBlackNot建議:

Close your browser and reopen it. Navigate to http://domain.com/page. 
If the site is using basic authentication, 
you should get a popup that says something like 
A username and password are being requested by 
http://domain.com. The site says: "foo bar". 
In this case, foo bar is the realm.

然后我就能登錄了,但頁面都是空的。 所以我添加了一個cookie:

$browser->cookie_jar({ file => ".mycookies.txt" });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM