Re: How to POST a form via Applescript: use javascript
Re: How to POST a form via Applescript: use javascript
- Subject: Re: How to POST a form via Applescript: use javascript
- From: Chris Adams <email@hidden>
- Date: Tue, 08 May 2001 00:54:46 -0400
On 5/6/01 10:12 PM Gary Beberman wrote:
>
I am writing an Applescript to test if a web site function (the
>
search engine) is in operation and, if not send an alert e-mail to
>
those responsible for keeping the function running.
>
>
Conducting the test means submitting a form via POST and checking the results.
>
>
I have tried methods with both IE/5 and Netscape 4.75. Both have
>
failed (sample code below).
>
>
Has ANYONE gotten a POST submission to work with IE (after 4.5) and
>
Netscape 4.7? If so, would you kindly provide a sample?
>
>
Thanks much,
>
>
Gary
>
Here is a little web page that automatically queries Google with a specific
term (HTML code to follow).
Use the Javascript submit() method in the body tag and build a little web
page containing only the form data that you want. This works in at least
IE4.5.
Save this file and open it with applescript. Then test for the results:
possibly by parsing the source code of the search window.
Here is one way to begin to parse code with IE4.5 and BBedit 5:
============ Applescript to get source
tell application "Internet Explorer 4.5"
set thesource to (GetSource of URL theURL)
end tell
tell application "BBEdit 5.1"
set thebbeditdoc to (make new document with properties {soft wrapping:false,
name:"thebbeditdoc"})
insert text thesource
end tell
============= Here is the HTML/javascript:
<html>
<head>
</head>
<!-- - - - - Here is the onload command - - - - -->
<body onload="theForm.submit()">
<!-- - - - - - - give the form a name - - - - - - -->
<FORM name="theForm" method=GET action=
http://www.google.com/custom >
<TABLE bgcolor=#FFFFFF><tr><td>
<A HREF=
http://www.google.com/custom>
<IMG SRC=
http://www.google.com/logos/Logo_40wht.gif border=0
ALT=Google align=absmiddle></A>
<INPUT TYPE=text name="q" size=31 maxlength=255 value="Applescript">
<!-- - - - - - - the submit button - - - - - - -->
<INPUT type=submit name="btnG" VALUE="Google Search">
<INPUT type=hidden name=cof VALUE="T:white;LW:400;
L:
http://google.com/logos/Logo_40blk.gif;LC:#FFC0FF;LH:100;
BGC:purple;AH:center;GL:1;GALT:yellow;AWFID:5e296cf425978c37;">
</FORM>
</body>
</html>
========= end HTML
Hope this helps!
--
Chris Adams
Cypress Lake Studios
Hypermedia, Quicktime, and Internet Design
http://www.cypresslakestudios.com
email@hidden