Hi, I'm new to Perl. Please take it easy on me.
I want to automatically login and download a Document from a university Platform, using WWW::Mechanize. The login seems to work, but after that I am not able to call any methods on my mechanize Object (I test this with ->title). I know that the site directly redirects after the login. Is this why the object is "broken"? Do I have to somehow deal with the redirect?
#!/usr/bin/perl use warnings; use strict; use LWP::Simple; use WWW::Mechanize; my $derp = WWW::Mechanize->new(); my $url = "myurl"; $derp -> cookie_jar(HTTP::Cookies->new()); $derp -> get($url); $derp -> content(); $derp -> follow_link(text=>"loginLink"); print $derp -> title(), "\n"; my @forms = $derp -> forms(); foreach (@forms) { my @input_fields = $_->param; print "form params are:\n"; foreach (@input_fields) { print "$_\n"; } } print "filling in form..\n"; $derp -> field("j_username", "user"); $derp -> field("j_password", "password"); $derp -> submit(); if($derp -> success()) { print "success\n"; } else { print "something went wrong\n"; } print $derp -> title(), "\n";
The output is success, but I get the following error: Use of uninitialized value in print at messing_around.plx line 43. I think that submit() returns something crap. Is this because I made a mistake or because of the redirect I should somehow deal with?
In reply to Mechanize login, but redirect. [SOLVED] by scarfguy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |