--- "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Here's my problem. I'd like to be able to do the equivalent of > the > following, using REALbasic and the HTMLViewer: > > (1) Go to http://rottentomatoes.com/. > (2) Type something in the main Search box. > (3) Click on "Go." To summarize what I snipped out, you want to find a URL you can use to go straight to the search, without manually (re-)typing the search term into the input box. Here's the step-by-step: 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. :) Mark Nutter Quick and easy regex creation and debugging! http://www.bucktailsoftware.com/products/regexplorer/ __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________ 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>
