このフォームを使用して認証するために3つの入力があるWebサイトにログインしようとしました。
<form action="/login.html" method="post">
<div class="loginlabel1 aright">ID / Email: </div>
<div class="bsearchfield">
<input type="text" name="profid" class="inputBx" size="15" value="" />
</div>
<div class="clear"></div>
<div class="loginlabel1 aright">Password: </div>
<div class="bsearchfield">
<input type="password" name="password" class="inputBx" size="15" value="" />
</div>
<div class="clear"></div>
<div class="loginbutton1">
<input name="login"type="image" src="images/logi.gif" align="right" border="0" />
</div>
</form>
ブラウザからログインすると、ログインに成功するとhttp://www.example.com/myhome.htmlにリダイレクトされます。
しかし、次のスクリプトはログインしておらず、同じlogin.html
ページを返します。私は何か見落としてますか?エラーメッセージが表示されません。投稿は成功しましたか?
#!/usr/bin/perl -w
use LWP 5.64;
my $browser = LWP::UserAgent->new || die " Failed LWP USER AGENT : $!";
$ENV{HTTP_proxy} = "http://proxy:port";
$browser->env_proxy;
$browser->cookie_jar({});
my @Header = (
'User-Agent' => 'Mozilla/4.76 [en] (Win98; U)',
'Accept' => 'image/gif, image/x-xbitmap, image/jpeg,image/pjpeg, image/png, */*',
'Accept-Charset' => 'iso-8859-1,*,utf-8',
'Accept-Language' => 'en-US',
);
push @{$browser->requests_redirectable}, 'POST';
$response = $browser->post(
"http://www.example.com/login.html",
[
'profid' => 'username',
'password' => 'password'
],@Header
);
$response->is_success or die "Failed to post: ", $response->status_line;
print "Successfully posted username and password.\n" if $response->is_fresh;
#printf("%s",$response->content);
printf("%s\n", $response->status_line);
printf("%s", $response->header("Accept-Ranges"));
printf("%s", $response->header("Age"));
printf("%s", $response->header("ETag"));
printf("%s", $response->header("Location"));
printf("%s", $response->header("Proxy-Authenticate"));
printf("%s", $response->header("Retry-After"));
printf("%s", $response->header("Server"));
printf("%s", $response->header("Vary"));
printf("%s", $response->header("WWW-Authenticate"));
delete $ENV{HTTP_PROXY};