Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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 http://www.jp.dk (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 = 'https://polid.jppol.dk/login.aspx?...blablabla...__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=...blablabla...&ctl00%24MainContent%24Login1%24UserName=MYUSERNAME&ctl00%24MainContent%24Login1%24Password=MYPASSWORD&ctl00%24MainContent%24Login1%24LoginButton=Log+ind';

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

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

$response = $browser->get('http://www.jyllands-posten.dk/protected/premium/indland/ECE5603687/ombudsmand-loefter-finger-over-for-rigets-embedsmaend/');

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!

Bib

Comment on https javascript form
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2014-11-24 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (147 votes), past polls