[REBOL] Re: handling html form from client
From: gscottjones:mchsi at: 10-Apr-2002 8:03
Hi, Michael,
From: "Michael Appelmans"
> I'm new to Rebol and thought I would try and impress my little brother
> with a new project. He is scanning the ISBN number of every book in my
> parents huge collection into a database. I was hoping to write a script
> to look up the books details (title, author etc) from bookfinder.com.
>
> Can anyone direct me to an example of filling in a form, sending it to
> the host and processing the resulting html. I'm not totally braindead so
> partial examples will suffice.
>
> Thanks in advance.
<snip>
I was unsure which form page you might have been looking for. The general
approach I use is to first look to see if the site uses a GET or a POST. If
it is a GET (which it appears to be), then I simply fill in a sample search,
grab the resulting URL and fit it into a template of the following form:
**************
REBOL []
site: http://www.bookfinder.com/search/
author: ""
title: ""
submit: "Begin+Search"
new_used: "*"
binding: "*"
isbn: "0-393-96945-2"
keywords: ""
min_price: ""
max_price: ""
currency: "USD"
mode: "advanced"
st: "sr"
ac: "qr"
either error? try [
page-return: read rejoin [
site {?author=} author {&title=} title {&submit=} submit
{&new_used=} new_used {&binding=} binding
{&isbn=} isbn {&keywords=} keywords {&min_price=} min_price
{&max_price=} max_price {¤cy=} currency
{&mode=} mode {&st=} st {&ac=} ac
]
][
page-return: "error"
][
print page-return
]
*******************
I usually embed this functionality into a function and pass in only the
field that will be queried. Then where I have "print page-return", I
usually put my parse functionality and return either the parsed info or an
appropriate error message. Hopefully this will get you started. POST is a
little different. I've done a few of those and can probably find an example
if needed.
Good luck.
--Scott Jones