I am trying to run the following code:
use WWW::Mechanize; use HTML::Form; use strict; my ( $content, $mech, $pass, $url, $user ); $user="user\@test.com"; $pass="mypass"; $url = "https://www.test.com". $mech = WWW::Mechanize->new(); push @{ $mech->requests_redirectable }, 'POST'; $mech->redirect_ok(); # get main page. $mech->get($url); die "ERROR(mech): ", $mech->response->status_line unless $mech->succes +s; # fill form with userid/pass and submit my $resp = $mech->submit_form( form_name => 'Login', fields => { USER => "$user", PASSWORD => "$pass" }, ); die "ERROR(resp): ", $resp->response->status_line unless $resp->is_suc +cess; # print output $content = $resp->content; die "ERROR can not get content: ", $mech->status_line unless $resp->is +_success; print $content; exit;
The idea is go get to the main page, fill out form with userid and password, and submit it. But, I get redirected instead, output is:
<HTML> <!-- File: redirectmeta.html --> <HEAD> <TITLE>Livelink - Redirection</TITLE> <META HTTP-EQUIV="Refresh" CONTENT="0; URL=/livelink815/livelink.exe?R +edirect=1"> </HEAD> </HTML> <!-- End File: redirectmeta.html -->
Please help, thanks.

In reply to WWW::Mechanize form gets redirected by vsevilla

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.