Applescript, AOL, & Webpages
Applescript, AOL, & Webpages
- Subject: Applescript, AOL, & Webpages
- From: List Guy <email@hidden>
- Date: Fri, 15 Jun 2001 14:53:19 -0700
"I need to write a script that will allow me to log on to a secure site. I
have the oneclick utility which records button scripts. I have been able to
log on to the secure site using this utility. However once I'm in the site
I need to be able to click on various buttons to access other areas of the
site. This is when I would like to call applescript back into action."
"How does one script a web page?"
Not with applescript. Applescript is an inter-application communication
language. It may "script" applicaitions only in so far as those applications
expose(er... permit) access to the "objects" recognized by that application.
For most applications, including browsers, these are windows, documents,
fields, cells, words.... This has nothing to do with the document object
model, dynamic html, or objects in javascript or on web page. No browser
exposes the html objects to applescript.
That said, all modern browsers (and I think this includes recent versions of
AOL's browser), support Javascript. Javascript is a language for -- among
other things -- manipulating the objects created by an HTML document: forms,
images, etc. It is possible with Internet Explorer (and *may* be possible
with other browsers) to create an applescript that tells IE to execute a
javascript. With javascript you can fill in fields, click buttons, etc. Be
warned, however, that secure sites uses hidden fields and other tricks to
prevent this (it improves security).
"What are the values and objects of a web page?"
If my understanding is correct, then you'll need a good book on javascript.
Try Flanagan's _Javascript_ (though it is a bit out-of-date) or Goodman's
_Javascript Bible_. Good luck.
"In the AOL dictionary there is an object class called tables."
I haven't attempted scripting AOL for a whiles, but this word "table" has
nothing do to with Excel tables, HTML tables, relational database tables,
coffee tables, or any other kind of table.
It's my understanding AOL's browser is a version of Internet Explorer
wrapped in AOL's custom software. I don't know how to tell (in the
applescript sense) the browser anything. I don't own AOL, so I cant' test
it, either.
"I know that a web page is written in HTML.
I know that the body of a web page is in a table."
Only if it's badly done, IMHO. No flames, please. (If anyone's opinion
differs, and anyone thinks tables are the beginning and end of web page
design, just say so. ) See above answer.
"I would be happy for any suggestions."
You're welcome. You have set yourself a daunting but doable task -- I think.
You'll need to learn a lot about AOL's applescript dictionary, applescript,
and javascript.
Now an example or two.
Here's a script that sets a window size in IE:
tell application "Internet Explorer" to set ie_windows_list to (ListWindows)
as list
set ie_size_window to "{window.resizeTo (300, 300);}"
tell application "Internet Explorer"
Activate
do script ie_size_window window (item 1 of ie_windows_list)
end tell
EXAMPLE 2
IF the following HTML is one page
<form name="aform">
<input type="text" name="test" size="9">
</form>
and that page is the frontmost page in IE THEN this applescript-javascript
combination will fill in the box with the word "welcome"
set js_script to "{document.aform.test.value='welcome';}"
tell application "Internet Explorer"
Activate
set ie_windows_list to (ListWindows) as list
do script js_script window (item 1 of ie_windows_list)
end tell
similar *javascript* can be written to "press" buttons, submit forms, etc.