Plankton has asked for the wisdom of the Perl Monks concerning the following question:
Friends,
I am trying to write a script that will allow me to access a webpage that is protected with Apache Basic Authentication, but I don't know how to pass the username and password to the server from my script:
Here's what happpens when I run it$ cat wwwPerl.pl #!/usr/bin/perl -w use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $url = "http://localhost/testauth/testauth.html"; $mech->get( $url ); print $mech->content();
I know I could use expect, but I don't fell like having to install Tcl right now. I know that WWW::Mechanize::Shell has an auth method. But I would want to automate things later on. Is there a way to automate WWW::Mechanize::Shell? Hmm...$ ./wwwPerl.pl <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>401 Authorization Required</title> </head><body> <h1>Authorization Required</h1> <p>This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.</p> </body></html>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing Apache Basic Auth. creditial with WWW::Mechanize?
by howie (Sexton) on Nov 22, 2004 at 08:57 UTC | |
|
Re: passing Apache Basic Auth. creditial with WWW::Mechanize?
by fglock (Vicar) on Nov 22, 2004 at 00:30 UTC | |
by Anonymous Monk on Nov 22, 2004 at 00:34 UTC | |
|
Re: passing Apache Basic Auth. creditial with WWW::Mechanize?
by Corion (Patriarch) on Nov 22, 2004 at 14:45 UTC | |
|
Re: passing Apache Basic Auth. creditial with WWW::Mechanize?
by TedPride (Priest) on Nov 22, 2004 at 14:42 UTC | |
by fglock (Vicar) on Nov 22, 2004 at 15:43 UTC |