Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Problems posting form with LWP

by dba (Monk)
on Nov 24, 2003 at 07:07 UTC ( [id://309465]=perlquestion: print w/replies, xml ) Need Help??

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

Perl Gurus, Iam a relatively newbie to perl. Not able to figure out what Iam doing wrong...
I have installed LWP and SSLRelay.
The form to post is:

https://egov.immigration.gov/graphics/cris/jsps/caseStat.jsp
The code:
---------
use strict; use LWP::UserAgent; my $browser = LWP::UserAgent->new; $browser->cookie_jar ({}); my $response = $browser->post ('https://egov.immigration.gov/graphics/ +cris/jsps/caseStat.jsp', [ "appReceiptNum" => "SRC02268xxxxx", "Submit" => "Search" ] ); print $response->content;
The form is not getting posted.
Please help.

20031124 Edit by BazB: Changed title from 'Javascript LWP'

Replies are listed 'Best First'.
Re: Problems posting form with LWP
by Koschei (Monk) on Nov 24, 2003 at 11:15 UTC
    As it appears you need cookies, you may find WWW::Mechanize to be of immense use as it automates all that sort of thing, including cookies, form handling, blah, blah, blah.
Re: Problems posting form with LWP
by cLive ;-) (Prior) on Nov 24, 2003 at 08:44 UTC
    I can answer this, because I was doing exactly the same thing :)

    The form will not work unless you have the session cookie set. Perform a GET on the page, then ensure you've got that cookie in your cookie jar when you submit the form.

    I couldn't be bothered to write code for this though, so I just created two bookmarks on my toolbar and clicked them quickly in succession ;-) One gets the page, the other loaded a form that autosubmitted itself with JS.

    .02

    cLive ;-)

    ps - you can see the cookie issue by navigating to the page, deleting your session cookie, then submitting the form.

      Thanks for replies. I can get the HTML page without any issues. The result HTML page should contain the status of the application receipt#. The perl script is not posting, and iam getting the same page as the link
      CLive,
      Could you please provide some sample code or link where I can see session cookie management?
      Koschei,
      I tried WWW::Mechanize, but it did not help...
        No code, but read this.

        cLive ;-)

Re: Problems posting form with LWP
by sauoq (Abbot) on Nov 24, 2003 at 07:40 UTC

    It is possible the server is rejecting the post because you fail to pass some other criteria such as a particular value for the Referer or UserAgent headers.

    If you control the server and know that to not be the case, you might check your error logs. You print the response... is it what you would expect it to be?

    -sauoq
    "My two cents aren't worth a dime.";
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 01:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found