Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Help with logging in to a tricky ASP web form with JavaScript using WWW::Mechanize

by Corion (Pope)
on Sep 30, 2011 at 22:26 UTC ( #928948=note: print w/ replies, xml ) Need Help??


in reply to Help with logging in to a tricky ASP web form with JavaScript using WWW::Mechanize

Have you looked at what your browser sends as data?


Comment on Re: Help with logging in to a tricky ASP web form with JavaScript using WWW::Mechanize
Re^2: Help with logging in to a tricky ASP web form with JavaScript using WWW::Mechanize
by OfficeLinebacker (Chaplain) on Sep 30, 2011 at 22:32 UTC
    Yes, if you read my post again, I'm sure you'll see I used "live http headers," which is a Firefox extension that allows me to examine what POST data my browser sends.

    I like computer programming because it's like Legos for the mind.

      You will need to replicate all data you see in the HTTP Live Headers, at least as long as submitting the form fails otherwise. You should also include ctl00_ContentPlaceHolder1_ctl00_rcbusertype_ClientState in your request, and also the __EVENTTARGET and other fields that the form has. The Live HTTP Headers should show you all values submitted, and you should also send all those values unless you know better.

        Looks like we cross posted; just want to note that I've never had to even mention the __EVENTTARGET, __EVENTARGUMENT, OR __VIEWSTATE parameters in order to get my programs to work, in my limited experience.

        I like computer programming because it's like Legos for the mind.
Re^2: Help with logging in to a tricky ASP web form with JavaScript using WWW::Mechanize
by OfficeLinebacker (Chaplain) on Sep 30, 2011 at 22:49 UTC
    Hey you know what? I did go ahead and look more closely at the headers after your post and I had been using a non-URL-decoded value for a parameter called ctl00_ContentPlaceHolder1_ctl00_rcbusertype_ClientState. The encoded value was %7B%22logEntries%22%3A%5B%5D%2C%22value%22%3A%22Subscriber%22%2C%22text%22%3A%22Subscriber%22%2C%22enabled%22%3Atrue%7D and I used http://meyerweb.com/eric/tools/dencoder/ to decode it so now the following works:
    $mech->set_fields( 'ctl00$ContentPlaceHolder1$ctl00$rcbusertype_Input' => "Su +bscriber", 'ctl00$ContentPlaceHolder1$ctl00$txtUserName' => $un, 'ctl00$ContentPlaceHolder1$ctl00$txtPassword' => $pw, ctl00_ContentPlaceHolder1_ctl00_rcbusertype_ClientState => '{"logEntries":[],"value":"Subscriber","text":"Subscriber" +,"enabled":true}' ); my $response = $mech->click_button( name => 'ctl00$ContentPlaceHolder1$ctl00$L +oginButton', x=>26, y=>10 );
    !

    I like computer programming because it's like Legos for the mind.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2014-08-20 06:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (105 votes), past polls