Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

https javascript form

by bib (Initiate)
on Jun 12, 2013 at 14:22 UTC ( #1038486=perlquestion: print w/replies, xml ) Need Help??
bib has asked for the wisdom of the Perl Monks concerning the following question:

Hi all

I'm new at this and maybe not the best to describe my problem! Here I go anyway.

Via LIVE HTTP Header I have found out that when logging into (javascript form) my browser is sending a loooooong HTTPS url to the server. When I manually use this url and afterwards try to open a need-to-pay-for-article, everything works perfectly.However, when I have my robot do exactly the same, it doesn't work:

my $url = '';

my $browser = LWP::UserAgent->new(keep_alive=>1, ssl_opts => { verify_hostname => 1 });

my $response = $browser->post( $url );

$response = $browser->get('');

print $response->content;

What code is generally necessary when sending a https-url?

Is it a problem that my username (which is contained in the https-url) includes a '@' which is converted to '%40'?

I have been searching for an answer for two days now :-( So I really hope you can help me out.

Thanks in advance!


Replies are listed 'Best First'.
Re: https javascript form
by PerlSufi (Friar) on Jun 12, 2013 at 15:32 UTC
    Hi, A couple things:
    first: it is perlmonks best practice to enclose your code in the "< code >" "< /code >" parameters (without the spaces between arrows and the word code)
    second: why don't you actually try to fill out the form on the page with LWP::UserAgent or WWW::Mechanize? I recently did a tutorial about WWW::Mechanize that explains this. I would personally just 'GET' the login page, fill out the forms and submit them. WWW::Mechanize has this.

      Thank you very much for your reply. It makes perfect sense to follow your tutorial :-)

      Only problem is that my login form has these three javascript input fields:

      <p>name="ctl00$MainContent$Login1$UserName"</p> <p>name="ctl00$MainContent$Login1$Password"</p> <p>name="ctl00$MainContent$Login1$LoginButton"</p>

      and I have no idea how to figure out how they work. I have tried looking at LIVE HTTP Header but the url that I think is relevant only puts the names like this:

      ctl00%24MainContent%24Login1%24UserName=[MYUSERNAME]&ctl00%24MainConte +nt%24Login1%24Password=[MUPASSWORD]&ctl00%24MainContent%24Login1%24re +memberMeCheckbox=on&ctl00%24MainContent%24Login1%24LoginButton=Log+in +d
        Now I have with success filled in the form's username and - I think - all other fields except the password which has no 'value' field. How do i get around that?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1038486]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2018-04-22 03:26 GMT
Find Nodes?
    Voting Booth?