I am currently trying to make a Perl program to use an HTTPS website. Now I can access the website fine. However, the second I try to submit any kind of form (even just click_button), then it leads to a 401 unauthorized question.
What could I be doing wrong? How come my credentials work fine when going to a page on the site, but the second I try any kind of form it leads to an error? Just to be clear I am a newbie at web-using programs so my coding might be sad. In this example, all I'm trying to do is click a "if you agree, click here" button to get past a disclaimer (get redirected here). Sorry for editing out the website, but it's not a public site.
Update - I tried just a simple follow_link, with the same unauthorized results. Just to be clear, my credentials are allowing me to go to a protected page (in a get(URL) statment). It's not letting me click on a link/form to go to a different page (even pages that work if I just use a get(URL) statement). I don't know if this will help, but without the MIME::Base64 use, I can't even 'jump' to a page. Still working on it.
Thank you.#!usr/bin/perl use strict; use warnings; require LWP::UserAgent; require HTTP::Request::Common; require HTTP::Response; use HTML::Form; use WWW::Mechanize; use MIME::Base64; my $username = 'username'; my $password = 'password'; my @args = ( Authorization => "Basic " . MIME::Base64::encode( $username . ':' . $password )); my $mech = WWW::Mechanize->new(); # I can remove the realm/host without affecting the 200 -> 401 occuran +ce $mech->credentials( 'www.edited.com:443', 'Title', $username, $passw +ord ); # enabling cookies, I'm not sure if I even need this part use HTTP::Cookies; $mech->cookie_jar( HTTP::Cookies->new( 'file' => '~/Desktop/programming/cookies.lwp', # where to read/write cookies 'autosave' => 1, # save it to disk when done )); # the site my $url = "https://www.edited.com/disclaimer.cgi"; $mech -> get ($url, @args); # HTML prints normally print $mech->content; # then I just want to click the button B1 $mech->click_button(name => 'B1'); # just in case it was a delay issue sleep(5); # then I get a 401 error print $mech->status(), "\n";
In reply to HTTPS WWW::Mechanize Form Problems by LE500
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |