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

My brain is starting to hurt.

I checked LWPcook, I read the other posts, all to no avail. I am trying to write a script that will grab successive web pages. The first step is to fill out a form and submit it through https to a JavaScript that will take the values given and generate a successive page, which I will also (down the road) need to munge. The relevant part of my script is:

$JSRequest = new HTTP::Request; # create new request %choices = (circuit => 'c7', district=> 'ALL', judge_type => '', jobSe +arch_year => '', judge_first => '', judge_last => '', open => 'R', closed => 'R', term => 'R', perm => 'R' +, TAB => 'viewJob', pos_open => 'on', pos_close => 'on', pos_term => 'on', pos_perm => 'on +', order_by =>'A', search => 'javascript:verify(document.forms[0])'); # save choices as associative array $JSRequest->header(Content-type => 'form-data'); # set content type $JSRequest = POST "$site", %choices; # Fill in all values expected by the form $JSRequestResult = $ua->request($JSRequest); # save response of the request stored in $JSRequest
The problem is this returns a few headers and then "You do not have a value in the TAB field." The tab field is defined in %choices. If I make
$JSRequest = POST "$site", %choices;
into
$JSRequest = POST "$site", \%choices;
I get: 500 Internal Server Error

and I have no way to check why, as the web server is not something to which I have access.

My question is: why am I getting this error? Does anyone have any ideas about how I could do this differently?

--- Chaos, fear and panic. My work here is done.

Replies are listed 'Best First'.
Re: At wit's end with LWP/https
by dash2 (Hermit) on Mar 14, 2001 at 23:52 UTC
    Looks like you are mixing HTTP::Request with HTTP::Request::Common. Only the latter lets you use the simple POST syntax.

    use HTTP::Request::Common; $request = POST $site, \%choices;

    Also, all your earlier messing around with $JSrequest gets nullified when you redefine it completely here:

    $JSRequest = POST "$site", %choices;

    Finally, I can't see the web page you are submitting to, but I would be very surprised if this works:

    search => 'javascript:verify(document.forms[0])');

    That would mean the script has to take the search variable and evaluate it, which seems unlikely. Normally scripts which take post variables are on the server - they may produce javascript output, but they don't use javascript themselves. But you know what you're doing.

    dave hj~

      Thank you for helping with the Request/Request::Common difference.

      The page I'm submitting to is here, if you want to see more directly what I mean. Try searching under the 7th circuit, all positions.

      With the

      search => 'javascript:verify(document.forms[0])');
      line, all I was trying to do was echo back every value on the page, including what happened when you hit the Submit button. It seems to make no difference ifit's there or not.

      As an aside, it may be dangerous to assume I know what I'm doing ;)

      ---Chaos, fear and disorder. My work here is done.

Javascript-only form Re: At wit's end with LWP/https
by andye (Curate) on Mar 15, 2001 at 20:08 UTC
    All dash2's points are good, also:

    Unusually, the form doesn't have a submit button.

    The form submitting is actually done by the javascript verify() function, loaded (at the top of the page) from https://lawclerks.ao.uscourts.gov:443/devl/web/scripts/web_verify.js, and called by <input type=button OnClick=javascript:verify(document.forms[0]);  name=search width=120 value='Search'  >

    The verify() function ends in

    f.action='https://lawclerks.ao.uscourts.gov/web/jobSearch'; f.submit()
    i.e. it sets the form action to the url given, then submits the form. So you don't want to set search => 'javascript:verify(document.forms[0])' -- that function isn't the value of the submit button, it's what gets called when you click on the submit button.

    It's interesting that they've chosen to do it this way - if the user doesn't have javascript (enabled), then the form won't work.

    andy.