{
package MyAgent;
use vars qw(@ISA);
@ISA = qw(LWP::UserAgent);
sub new {
my $self = LWP::UserAgent::new(@_);
$self->agent("lwp-request/$LWP::UserAgent::VERSION");
$self;
}
# this routine gets called when your browser
# would otherwise be asked to provide a
# username and password
sub get_basic_credentials {
my ($self, $realm, $uri) = @_;
print( STDERR " - providing auth to realm \"$realm\"\n" );
return( $username, $password );
}
}
####
{
package MyMech;
use vars qw(@ISA);
@ISA = qw(WWW::Mechanize);
sub new {
my $self = WWW::Mechanize::new(@_);
$self->agent("www-mechanize/$WWW::Mechanize::VERSION");
$self;
}
# this routine gets called when your browser
# would otherwise be asked to provide a
# username and password
sub get_basic_credentials {
my ($self, $realm, $uri) = @_;
print( STDERR " - providing auth to realm \"$realm\"\n" );
return( $username, $password );
}
}
####
my $mech = MyMech->new();
$mech->get( $url );
print $mech->status, "\n";
print $mech->success;