LE500 has asked for the wisdom of the Perl Monks concerning the following question:
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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTTPS WWW::Mechanize Form Problems
by zentara (Cardinal) on Jan 21, 2009 at 17:33 UTC | |
|
Re: HTTPS WWW::Mechanize Form Problems
by perrin (Chancellor) on Jan 21, 2009 at 18:35 UTC | |
|
Re: HTTPS WWW::Mechanize Form Problems
by bart (Canon) on Jan 23, 2009 at 20:06 UTC | |
|
Re: HTTPS WWW::Mechanize Form Problems
by imrags (Monk) on Jan 22, 2009 at 07:49 UTC | |
by LE500 (Initiate) on Jan 22, 2009 at 18:47 UTC | |
by Corion (Patriarch) on Jan 22, 2009 at 18:50 UTC | |
by LE500 (Initiate) on Jan 22, 2009 at 20:34 UTC | |
by Corion (Patriarch) on Jan 22, 2009 at 20:41 UTC | |
|
Re: HTTPS WWW::Mechanize Form Problems
by whakka (Hermit) on Jan 21, 2009 at 19:13 UTC | |
by LE500 (Initiate) on Jan 22, 2009 at 18:45 UTC | |
|
Re: HTTPS WWW::Mechanize Form Problems
by Corion (Patriarch) on Jan 23, 2009 at 22:32 UTC | |
by LE500 (Initiate) on Jan 23, 2009 at 23:06 UTC | |
|
Re: HTTPS WWW::Mechanize Form Problems
by LE500 (Initiate) on Jan 23, 2009 at 19:49 UTC |