Mark,

1. Do "View Source" on the page.

2. Use the Find command to locate the "<form" tag that contains
the search inputs.  In this case, the third form is the one we
want (helpfully labelled with an HTML comment as "BEG SEARCH").

3. Notice the attributes in the form tag.  In this case, the form
tag is:

<form name="searchform" method="get" action="/search/search.php">

The action tag tells us that the URL is going to start with
"http://www.rottentomatoes.com/search/search.php"; -- plus a
question mark, which separates the URL for the search page from
the actual search terms themselves.

4. Between the <form> tag and the </form> closing tag, there will
be a number of <input> and <select> tags (and/or <textinput>
tags).  In this case, we find the following tags (slightly
abbreviated to hilite the important attributes):

<input type=text ...name=search...>
<select name=searchby...">
        <option value="all" selected>All</option>
        <option value="movies" >Movies</option>
        <option value="games" >Games</option>
        <option value="celebs" >Celebs</option>
        <option value="critics" >Critics</option>
        <option value="sources" >Sources</option>
</select>
<input type="image"...">

We can ignore the last <input> tag--if the type = "image" then
it's just a graphical submit button, especially since there are
no "name" and "value" tags.  We're only interested in tags that
have names and values.

5. Ok, our partial URL is
"http://www.rottentomatoes.com/search/search.php?";.  The next
step is to add a name/value pair for each of the input/select
fields in the form.  First we have to get them ready to submit,
however.  For each value, do the following:

5a. Convert each value using RB's EncodeURLComponent function.
5b. Take the resulting value and do ReplaceAll(" ", "+") to
convert all spaces to plus signs.

Note: for the values of the <select> field, make sure you use
only the values that appear in the <option> tags inside the
<select> tags.

6.  Now we put them together:

theURL = partialURL + "search=" + convertedSearchValue + _
 "&" + "searchby=" + convertedSearchByValue

Notice we're using the name we got from the "name=" attribute for
each input/select tag.  Use the "name=value" format (no spaces!)
with an ampersand ("&") between name/value pairs.

That's it!  It might look a little complicated since I spelled
out all the details, but it's really a fairly simple task.  The
only tricky part is sifting through all the HTML/Javascript to
find the form and field names you're looking for. :)
One thing I'm trying to do is go to a particular Web page and fill in, say, four forms (not just one). Can this same approach be used to do that?

I'm guessing that it may be possible (or maybe not), but the following may present a problem: I'd like to stay on the same page rather than going to another URL. Is it possible to stay at the same URLwith the forms filled in (and how do I feel them in using REALbasic)?

Barry Traver

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to