Re: scripting submitting a form
Re: scripting submitting a form
- Subject: Re: scripting submitting a form
- From: Charles Arthur <email@hidden>
- Date: Fri, 22 Jun 2001 10:22:58 +0100
On Thu, 21 Jun 2001 20:42:15 -0400, Brian <email@hidden> wrote:
>
Jeff Baumann wrote:
>
> Why use IE? I would use URL Access Scripting. It allows form submission and
>
> you can then parse the reponse page and automate whatever next step you
>
>plan.
And Jeff is indeed right.
Brian wrote:
>
I thought browser rather than URL access because:
>
>
1- Never tried a project like this before and probably didn't know the right
>
question to ask or what alternatives I could consider.
Yeah, scripting the browser seems smart, but when you pick apart the
underlying HTML you realise that posting a form simply means sending the
http server a list of named variables and their values.
>
2- I'm unsure how/if I can build what I want so starting from a browser
>
seemed logical. I know how to accomplish my task manually in the browser,
>
so I just need to learn how to control the same steps through AS.
Often the case that we can see how to move the mouse, but not how to script
it. You have to get inside the computer's way of doing things, to see how
*it* would accomplish the task if all the imput from you disappeared.
>
3- My goal being to modify data in an Oracle DB for which a fairly
>
sophisticated web front end exists, I intend to "set up my environment" --
>
query the DB manually through a browser, then invoke the Applescript to act
>
on the results of the query which are returned as web pages comprised of
>
forms, submit the forms back, modifying the data, repeat as needed.
Coo. Anyway. URL forms is forms, mostly.
Here's an example script I wrote (with the help of the list) to query a web
news/search engine called ananova.com. The original page that has the forms
in is at
http://www.ananova.com/search/index.html and you'd have to save
the page and then see what variables there are to see how these are then
satistifed by the form data.
My search terms are "climber" and "mountaineer" (searched in separate
iterations of the loop). This is the bare bones of the script; the parsing
and modification of the result isn't small beer, but that's over to you.
set searchtermlist to {"climber", "mountaineer"}
repeat with searchterm in searchtermlist
set errormsj to ""
set formdata to ("QUERY00=" & searchterm &
"&SAVEDB=ananova&ORGANISE_CODED=R:date&DAYSMINUS=5") as string
tell application "URL Access Scripting"
try
download
"
http://www.ananova.com/search/index.html" to thefile form data formdata
replacing yes
--following line is for non-repeat-loop
version, searches for "climber"
--download
"
http://www.ananova.com/search/index.html" to thefile form data
{"QUERY00=climber&SAVEDB=ananova&ORGANISE_CODED=R:date&DAYSMINUS=5"}
replacing yes
on error error_message
set errormsj to text of error_message
end try
end tell
end repeat
Note though that some forms pages - Java-based or Javascript-based ones -
will be really hard to break apart to see what they do to the variable
values you submit.
best
Charles
----------------------------
http://www.ukclimbing.com : 1000+ British crags, 350+ British climbing
walls - searchable by distance and anything else you care to think of -
with weather forecasts for every one, plus maps, articles, news and
features. Plus Britain's busiest climbing discussion boards. And there's
even a cool shop attached.