in reply to Re^2: $mech->content() returns empty
in thread $mech->content() returns empty

I tried condensing the code a little bit to make it easier to figure out what goes wrong. The CONTENT is still empty but the URL shows that it did infact redirect to the proper page!

In theory I could just get that URL, but it'd be a new instance of it when I need to know what the exact source code was once the form was submitted (to check for login errors).

Any other suggestions?

use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->cookie_jar(HTTP::Cookies->new); $mech->get( $forum_login ); if ($forum_type eq "number") { $mech->submit_form( form_number => $forum_call, fields => { $forum_user => $username, $forum_pass => $password, } ); die "Couldn't submit form" unless $mech->success; my $stuff = $mech->content; print $stuff; my $url = $mech->uri; print $url; }

Replies are listed 'Best First'.
Re^4: $mech->content() returns empty
by diotalevi (Canon) on Oct 13, 2006 at 23:55 UTC

    You can selectively disable the redirection. I suppose that if you need to examine something on the pre-redirect page that you'd use that feature.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      Here's more information I've come across.

      When the user signs in CORRECTLY, it does redirect. If they sign in wrong, it stays at the page of the form's action attribute.

      I made sure the login info was WRONG and I can capture the page and get it to let me know it did not sign in.

      HOWEVER, when I add the right information to login, it apparently goes through the redirect (assuming this because $mech->content is empty) BUT my forum's activity box shows no user has signed in for the last 15 minutes.

      For some reason it THINKS it is signing in but it can't be. Could some javascript on the page be throwing WWW::Mech off?

        WWW::Mechanize doesn't know anything about JavaScript and doesn't execute any of it.

        ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊