
lsamagana
New User
Sep 4, 2012, 8:04 AM
Post #1 of 4
(1867 views)
|
Redirecting to a URL Using LWP::SIMPLE
|
Can't Post
|
|
Hi, I am trying to get the contents of the webpage, but I am getting the contents of the login page, its not redirecting to the page once logged in. Code that I have written use LWP::UserAgent; use LWP::Simple; $username = "abcd"; $password = "xxxxxx"; # Prepare request. my $ua = new LWP::UserAgent; my $req = new HTTP::Request(GET => 'http://perlguru.com/gforum.cgi?do%3Dpost_write%3Bforum%3D2=Post+New'); $req->authorization_basic($username, $password); # Request file. my $res = $ua->request($req); # Check if request was successful. #if ($res->is_success) { print $res,"\n"; if($res->is_success and $res->previous){ print $req->url, ' redirected to ', $res->request->uri, "\n"; my $resu = get $res->request->uri; print $resu When I print this I get the contents of the Login page not the actual page which has been specified. Can anyone help me in this?
|