In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Vincent A. Primavera) writes: >Hello, > Using the mech-dump utility I get the error listed below when trying >to access this page. I do have the login information. Does anybody know >how I can supply it and get around this? >-- > Thank you, > > Vincent A. Primavera. > M.I.S. Manager. > Ralph Pill Electric Supply Co. > >C:\Temp>mech-dump.pl --forms http://www.road.com/clients/fleetASAP/index.pl >Can't fetch http://www.road.com/clients/fleetASAP/index.pl >401 Authorization Required
This requires a patch to mech-dump in order to be able to pass the information in. So I made a patch (below). Supply the username and password together with a colon between them, viz: mech-dump -auth me:secret ... Copied to Andy. --- mech-dump.orig 2003-11-16 08:35:45.000000000 -0800 +++ mech-dump 2003-11-16 09:28:29.000000000 -0800 @@ -16,6 +16,7 @@ my @actions; my $absolute; +my $auth; GetOptions( forms => sub { push( @actions, \&dump_forms ); }, @@ -23,6 +24,7 @@ images => sub { push( @actions, \&dump_images ); }, all => sub { push( @actions, \&dump_forms, \&dump_links, \&dump_images ); }, absolute => \$absolute, + "auth=s" => \$auth, help => sub { pod2usage(1); }, ) or pod2usage(2); @@ -38,6 +40,7 @@ --all Dump all three of the above, in that order --absolute Show URLs as absolute, even if relative in the page + --auth cred Provide credentials as username:password --help Show this message The order of the options specified is relevant. Repeated options @@ -54,7 +57,14 @@ @actions = (\&dump_forms) unless @actions; my $mech = WWW::Mechanize->new( cookie_jar => undef ); -my $response = $mech->get( $uri ); +my @args; +if ($auth) +{ + require MIME::Base64; + @args = (Authorization => "Basic " . + MIME::Base64::encode($auth)); +} +my $response = $mech->get( $uri, @args); $response->is_success or die "Can't fetch $uri\n", $response->status_line, "\n"; $mech->is_html or die "$uri returns type \"", $mech->ct, "\", not \"text/html\"\n"; -- Peter Scott http://www.perldebugged.com/ *** NEW *** http//www.perlmedic.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]