in reply to LWP and Logging into webpages

Try something like this:
use HTTP::Request; use LWP::UserAgent; use strict; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(POST=>'http://192.168.0.1/authtest/index. +html'); $req->authorization_basic('yourname', 'password'); my $content = $ua->request($req)->as_string; print "Content is $content";

Replies are listed 'Best First'.
Re: Re: login???
by maddfisherman (Sexton) on Jun 22, 2002 at 23:39 UTC
    i tried this to experiment... the goal was to get the content of my default page once ive logged in into $content
    #!/usr/bin/perl use strict; use HTTP::Request; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(POST=>'http://perlmonks.com/index.pl'); $req->authorization_basic('maddfisherman', '********'); my $content = $ua->request($req)->as_string;
    but this just gives me the default page not my page after i log in.
      Perlmonks doesn't use web server authorization like that. It's all cgi script-based authentication based on cgi params or cookies.
      # UNTESTED use HTTP::Request; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(POST=>'http://perlmonks.com/index.pl?op=l +ogin;user=maddfisherman;passwd=******'); my $content = $ua->request($req)->as_string;
      And if you're thinking of writing a votebot, don't. :)
        i tried it... this also returns the perlmonks homepage.