Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: POSTing with LWP::UserAgent

by Anonymous Monk
on Jan 08, 2001 at 08:06 UTC ( [id://50432]=note: print w/replies, xml ) Need Help??


in reply to POSTing with LWP::UserAgent

Here's an example for you, that works OK, except for a bug that I need help with. the POST is here, and the form is below. The thing is, I can't get it to set the checkbox values and I can't find any doc anywhere to tell me how. I did this working from Orwant & Gruhl's article in TPJ 4:1. Any help would be a godsend!
sub getLinkParse { use LWP::UserAgent; use HTTP::Request::Common; $sentence = "This is a test sentence."; $response = (new LWP::UserAgent)->request(POST 'http://www.link.cs.cmu.edu/cgi-bin/link1/construct-page-4 +.cgi#submit', [ Sentence => $sentence, Constituents => "1", <<<< this is a checkbox NullLinks => "1", <<<< this is a checkbox AllLinkages => "OFF", LinkDisplay => "on", ShortLength => "6", PageFile => "/docs/submit-sentence-4.html", InputFile => "/scripts/input-to-parser", Maintainer => "sleator\@cs.cmu.edu" ] ); exit -1 unless $response->is_success; $_ = $response->{_content}; print $_; } This is the origianl form on the site: <FORM METHOD="POST" ACTION="/cgi-bin/link1/construct-page-4.cgi#submit +"> <textarea name="Sentence" MAXLENGTH=200 wrap=virtual rows=3 cols=70>< +/textarea><br> <INPUT TYPE="checkbox" NAME="Constituents" CHECKED>Show constituent tr +ee &nbsp; <INPUT TYPE="checkbox" NAME="NullLinks" CHECKED>Allow null links &nbsp +; <INPUT TYPE="checkbox" NAME="AllLinkages" OFF>Show all linkages &nbsp; <INPUT TYPE="HIDDEN" NAME="LinkDisplay" VALUE="on"> <INPUT TYPE="HIDDEN" NAME="ShortLength" VALUE="6"> <INPUT TYPE="HIDDEN" NAME="PageFile" VALUE="/docs/submit-sentence-4.ht +ml"> <INPUT TYPE="HIDDEN" NAME="InputFile" VALUE="/scripts/input-to-parser" +> <INPUT TYPE="HIDDEN" NAME="Maintainer" VALUE="sleator@cs.cmu.edu"> <br> <INPUT TYPE="submit" VALUE="Submit one sentence"> <br> </FORM>

Replies are listed 'Best First'.
Re: Re: POSTing with LWP::UserAgent
by chromatic (Archbishop) on Jan 08, 2001 at 10:18 UTC
    Checkboxes without explicit VALUE fields return "ON". At least, in web browsers that follow the specifications. :)

    Try that instead of "1".

      Thanks for the suggestion re checkboxes. I tried "ON", "CHECKED", "1", "Dammit" -- none of them worked. In general, where can I find more information about this? I'm sure my next problem will have radio buttons or something else I don't know how to do! ...
        I suggest you may want to save the form to disk and change the form action url to point to a cgi that does nothing but display its parameters ( a useful thing to have sometimes, and trivial to write ). Then open the form in the browser usually used, and submit the form, then look at what is being passed for the checkboxes in the query.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-16 16:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found