Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

You simply need to tell Mech to do whatever “clicking on that hyperlink” would do.   This can be easy, or it can be hard.   :-)

It’s easy when the hyperlink is a simple href="somewhere" ... all that you need to do is to tell Mech to follow_link().   If it is a button or an image, you can click() it.   (Or, if you know what the link is and that it will never change, you can simply send Mech to its destination.   However, that approach creates a dependency between your script and the server’s ... if they change their code, your script will break.)

Things get harder when the designer of the form chooses instead to use JavaScript, with a onclick="" handler.   WWW::Mechanize::FAQ has a specific section discussing the implications of JavaScript.   Most of the time, cursory examination of the JavaScript code will reveal what it actually sends back to the host, and you can do that directly.

Successful login will undoubtedly work by sending you back a cookie, along with a redirect.   Mech can store the cookie and follow the redirect.   But, remember to correctly handle the case where the login is not correct, or some kind of server error is thrown, even if you are using “known good” credentials in your program.


In reply to Re: Establish a session to call URL with Perl by sundialsvc4
in thread Establish a session to call URL with Perl by rodms

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2014-12-21 00:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (100 votes), past polls