--- Barry Traver <[EMAIL PROTECTED]> wrote:

> What I'm trying to do is this:  Go to a particular Web page and
> use 
> REALbasic to fill in, say, four forms on the Web page.  How
> would I go 
> about doing that?

It's not easy, or foolproof.  The approach I would try would be
to use HTTPSocket.Get to retrieve the raw HTML, then use a RegEx
to modify the web page and save it to a temporary file, then load
the temp file into an HTMLViewer.

There are two changes that need to be made.  First, you have to
add a tag to the header that looks like this:

<base href="*URL-of-Downloaded-Page*"/>

where "*URL-of-Downloaded-Page*" is the actual URL you got the
page from.  This is so that any relative links go back to the
original web site instead of trying to load from your hard drive.
 Be sure and check whether there's already a <base> tag in the
raw HTML before you add your own.  If there isn't, you can just
do

  rawHTML = rawHTML.Replace("</head>", _
    "<base href=""*theURL*""/></head>")

The second replacement is trickier:  for every field you want to
fill in, find the <input> tag, and replace it with an <input> tag
that has a value attribute containing the text you want to fill
in to the fields.  That is, instead of 

  <input type="text" name="userid" length="40"/>

you want it to say

  <input type="text" name="userid" length="40" value="joeuser"/>

Set the RegEx.Options "Greedy" flag to false, and then you can
use a search pattern like

  <input (.*)name="userid"(.*)/>

and replace it with

  <input \1name="userid"\2 value="joeuser"/>

Some forms (like the login form for Yahoo Mail) use fancy
JavaScripts to govern the input of data into the form fields,
precisely to thwart attempts to access the form by a "robot" (I
assume).  The above technique won't work for them.

I'm doing this from my non-RB computer again, so I haven't tested
it, but that's the basic outline, and I believe it should work. 
When it comes up in the browser, all the fields will be filled in
with the values you desire.

The alternative approach would be to write a JavaScript that does
what you want, and then tweak the header so that it included both
the <base> tag and the JavaScript code you wanted.  Might be a
little easier, though I doubt whether it would get around the
Yahoo login security.


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>

Reply via email to