Re: How to fill in web form as "open location" url?
Re: How to fill in web form as "open location" url?
- Subject: Re: How to fill in web form as "open location" url?
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 29 Jun 2006 16:54:21 -0400
On 6/29/06, Eric Geoffroy <email@hidden> wrote:
I'm attempting to construct a form URL with either AppleScript or curl.
Goal: Insert ISBN (text string) and submit the form.
A little nit-pickiness to start: what you are attempting to do is
simulate the submission of a web form from a browser, which is not
quite "constructing a form URL". First, a "form URL" is the URL of
the form, not necessarily the URL it submits to; and second,
submitting a form involves more than just constructing a URL. It's
all about what you do with that URL.
If you just stick name=value pairs on the end of the URL and issue an
HTTP GET request for the result, that might work, or it might not.
Notice that the <form> element specifies a method of "POST", which
means it expects you do issue an HTTP POST request rather than a GET
request. Action handlers frequently deal with both kinds of requests
interchangeably, but sometimes not.
But you must also send all of the values expected by the action URL,
not just the one you're trying to fill in. Presumably, they have
their form set up to do this, so you just need to emulate what it
does. You must especially include all the hidden inputs. Also,
notice that the place where you enter the ISBN is not an input named
"isbn"; the name of an input doesn't change dynamically (unless
there's JavaScript that changes the HTML itself), so the input doesn't
have a name tied to any of the various search methods like isbn;
instead, it's named "searchterm".
So the full query string (that is, the part after the ? in the URL)
will be something like this:
operator=C&authoperator=C&main_title_ind=1&searchtype=isbn&searchterm=0131435965
You can easily construct the full URL by saving a local copy of the
form, changing the "post" to a "get", loading it in your browser and
submitting it; the full URL with query string attached will then be in
your location bar for you to copy and paste whithersoever you will.
If you find that their result.cfm page does not, in fact, honor GETs,
then you have to issue a POST request, which basically means that the
above query string is fed as standard input to the HTTP connection
instead of being part of the URL. I'll let someone else explain how
best to do that from AppleScript...
Leaving the form here for reference:
<a href="/index.cfm" id="logoHREF" title="GHEPM Home"></a>
<div id="quicksearch">
<FORM NAME="quicksearch" METHOD="post" ACTION="result.cfm"
TARGET="_parent" onSubmit = "return sub_form();">
<INPUT TYPE="HIDDEN" NAME="operator" VALUE="C">
<INPUT TYPE="HIDDEN" NAME="authoperator" VALUE="C">
<INPUT TYPE="HIDDEN" NAME="main_title_ind" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="active_ind" VALUE="1">
<INPUT TYPE="hidden" NAME="title" VALUE="">
<INPUT TYPE="hidden" NAME="author" VALUE="">
<INPUT TYPE="hidden" NAME="isbn" VALUE="">
<INPUT TYPE="hidden" NAME="pearid" VALUE="">
<SELECT id="searchtype" name="searchtype" onchange="setFocus
('searchterm');">
<OPTION value="isbn" selected>ISBN:</OPTION>
<OPTION value="author">Author:</OPTION>
<OPTION value="title">Title:</OPTION>
<OPTION value="peaid">Pea ID:</OPTION>
</SELECT><INPUT id="searchterm" name="searchterm"/><INPUT
id="qsearchbutton" name="qsearchbutton" type="image" title="GO"
alt="GO" src="/images/118104_go.gif">
</FORM>
</div>
Here's what I tried:
open location "http://hep.chindogu.com/result.cfm?isbn=0131435965"
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden