Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

www::mechanize matchup.io form and clicking

by rocteur (Acolyte)
on Apr 18, 2015 at 20:29 UTC ( [id://1123902]=perlquestion: print w/replies, xml ) Need Help??

rocteur has asked for the wisdom of the Perl Monks concerning the following question:

I'm only learning to use www::mechanize and I've had some luck but now I'm stuck and frustrated with this one.

Trying to login to matchup.io, so I ran mech-dump -forms https://matchup.io/users/sign_in

POST https://matchup.io/users/sign_in utf8=&#10003; (hidden readonly) authenticity_token=diJec2QOaXyKKSFfemWgQhfJo1Y9zIPg2PyiF9oajMK/JlmhI +g7HOQvuy3BlVMx0jUvZIX8xeh5kNbDm+MqCLA== (hidden readonly) user[remember_me]=1 (hidden readonly) user[email]= (email) user[password]= (password) button=<UNDEF> (submit)

I've not had a mixture of fields and button but to make it worse, the brackets in the fields, see user email and password aboveand they give me all sorts of errors whatever I try.

Does anyone have any idea how to prepare the fields with brackets and then the button..

Thanks in advance.

Oh, it's my first post here so accept my apologies if I'm doing something wrong in the post

Replies are listed 'Best First'.
Re: www::mechanize matchup.io form and clicking
by hippo (Bishop) on Apr 18, 2015 at 20:45 UTC

    Welcome to the monastery, rocteur.

    they give me all sorts of errors whatever I try

    If you perform an action which results in an error and seek some help to avoid producing the error it is usually a good idea to tell the potential helpers what the exact error message was and what the exact code was which you executed to cause it. Without that information the potential helpers could spend a lifetime guessing and guessing and guessing what the underlying problem might be.

    Are you familiar with the SSCCE concept? If you can provide one of those the monks will be more inclined to help you in your quest.

      The point I was trying to make is that the form items that need to be posted contain square brackets
      user[email]= (email) user[password]= (password)
      I imagined people in this group who know www::mechanize would see the issue help me understand how to pass this to the from as the obvious way to me does not work

      As I said I'm only just learning www::mechanize and whilst searching for help I saw people write that members of this site know www;:mechznize..

      $agent->submit_form( form_number => 1, fields => { user[email] => $login, user[password] => $passwor +d }, );
      syntax error at ./mechaM.pl line 20, near "user[" Execution of ./mechaM.pl aborted due to compilation errors.
        I'm not sure it solves your problem, but to create a hash with the keys specified in Perl, you have to quote the keys, as they aren't simple barewords:
        fields => { 'user[email]' => $login, 'user[password]' => $pas +sword },

        See perlop for details:

        The => operator is a synonym for the comma except that it causes a word on its left to be interpreted as a string if it begins with a letter or underscore and is composed only of letters, digits and underscores.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        If this is "the point that you are trying to make," then be sure to make that clearly. Emphasize it. When your question is clear and direct, an answer follows quickly. If not, confusion and requests for clarification.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1123902]
Approved by hippo
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found