Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > applescripting safari, automating safari, or realbasic-ing an htmlviewer

applescripting safari, automating safari, or realbasic-ing an htmlviewer
Thread Tools
mgl
Mac Enthusiast
Join Date: Oct 2001
Location: Canada
Status: Offline
Reply With Quote
Oct 18, 2006, 05:18 PM
 
Arg! I've had a frustrating day trying to do something that would have been so simple prior to cross-site scripting. I'm trying to take a web form, enter one value into it, grab the results, go back to the form, enter a value increment by one, grabbing the results, etc. So I need to be able to enter the form value, copy the result text, loop, and increment.

I first decided to try this with Automator. It doesn't support looping or incrementing, let alone variables. I can get it to do it in one pass, but I can't get it to loop (I could try the automator loop applescript utility), but even if that worked, I'd have no way to increment my counter or to put the incremented counter into the form since the form setting utility I found doesn't take result values from previous actions. Is there a way to do this with Automator?

I then tried RealBasic. The form won't work with httpsocket so I used htmlviewer. Nice, but there's no way to navigate to fields on a form and no way to execute javascript to submit the form, or is there?

I finally tried AppleScript and had bad flashbacks to the nineties. While AppleScript looped and incremented to my heart's content, I couldn't get it to grab the document source. I think I'm forgetting someting about applescript and scope.

tell application "BBEdit"
set scratchPad to make new document
end tell

and later on in safari
set contents of scratchPad to the source of document 1 as text

When this line runs, I get a scratchPad is not defined error. I tried defining it at the start of the script but went nowhere.

This would have been so much easier with javascript in another frame, but cross-site scripting ended that. I should just dig up an old machine with IE 4 on it. Sigh.

Can somebody tell me which is the best tool for doing this, or what I'm doing wrong in AppleScript?

Thanks
     
Grizzled Veteran
Join Date: Jan 2002
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Nov 12, 2006, 06:07 AM
 
I think I would just write a shell script that used wget (or curl) to get the web page and then some suitable use of grep to get what you want out of it and then resubmit with extracted values.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:39 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2