Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: click button

by Corion (Patriarch)
on Oct 31, 2015 at 20:24 UTC ( [id://1146593]=note: print w/replies, xml ) Need Help??


in reply to click button

Looking at the HTML source of the "Continue" button:

<input type="image" src="images/continue-blue.gif" width="73" height=" +17" alt="Continue" border="0" onclick="check_fields();">

That button uses Javascript. WWW::Mechanize does not support Javascript.

There are different approaches for you to proceed:

You could look at the Javascript source code of that site and figure out what the Javascript does, and replicate that with Perl.

You could use (for example) Firefox HTTP Live Headers to find out the HTTP requests that the browser makes in response to the button being clicked, and replicate them with Perl.

You could automate a web browser that understands Javascript, like WWW::Mechanize::Firefox, WWW::Mechanize::PhantomJS and maybe others.

Replies are listed 'Best First'.
Re^2: click button
by davidstoll (Initiate) on Nov 08, 2015 at 15:24 UTC
    I have the javascript that passed through the console. How do I "convert it" to Perl? Specifically, I believe this is the key part of the code:
    "postData": { "mimeType": "application/x-www-form-urlencoded", "text": "loginFrn=0123456789&loginPassword=PasswordX&x=28& +y=6", "params": [ { "name": "loginFrn", "value": "0123456789" }, { "name": "loginPassword", "value": "PasswordX" }, { "name": "x", "value": "28" }, { "name": "y", "value": "6" } ]
    I can give you the full code if that isn't correct, but if it is, what does the converted code look like?

      This looks more like data that happens to be readable as a JSON data structure than Javascript code. If you don't know Javascript, then you will need to find somebody who can read the Javascript and tell you what it does or you will need to use one of the other approaches I outlined already, like finding out what the Javascript does and replicating that with Perl or using an implementation of WWW::Mechanize that understands Javascript.

      Just guessing from the content of the data, I would assume that the Javascript simply sends a POST request with the MIME type application/x-www-form-urlencoded and some parameters. If you are wildly guessing, you could try to construct a HTTP::Message that contains that data and see if that already works for you.

      A bit of HTML and HTTP understanding will be necessary though.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found