Re: applescript and browsers
Re: applescript and browsers
- Subject: Re: applescript and browsers
- From: J Charles Ferrari <email@hidden>
- Date: Wed, 21 Jan 2004 14:51:39 -0800
I am not an expert on curl, but I have been unable to make it work on
some sites, such as
http://zip4.usps.com/zip4/zip4_responseA.jsp?
set theAddress to "1600 Pennsylvania Ave NW"
set theZip to "20500"
set theCurlCommand to "Curl -d Selection=1 -d address1=" & theAddress &
" -d address2= -d city= -d state= -d zipcode=" & theZip & "
http://zip4.usps.com/zip4/zip4_responseA.jsp"
set theZipCodeInformation to do shell script theCurlCommand
results in:
"<HTML><HEAD><TITLE>Server Error</TITLE></HEAD>
<BODY><H1>Server Error</H1>
This server has encountered an internal error which prevents it from
fulfilling your request. The most likely cause is a misconfiguration.
Please ask the administrator to look for messages in the server's error
log.
</BODY></HTML>"
replacing the spaces in theAddress with " " produces the same error
as does replacing them with "+"
The following, using Safari, works:
set theAddress to "1600 Pennsylvania Ave NW"
set theZip to "20500"
tell application "Safari"
make new document at beginning of documents
set URL of result to "
http://www.usps.com/zip4/welcome.htm"
end tell
delay 3
set theJS to "document.forms.frmzip.address1.value=\"" & theAddress &
"\";
document.forms.frmzip.zipcode.value=" & theZip & ";
document.forms.frmzip.address.value=document.forms.frmzip.address1.value
;"
set theSubmitter to "document.forms.frmzip.submit();"
tell application "Safari"
set x to (do JavaScript theJS in document 1)
set z to (do JavaScript theSubmitter in document 1)
delay 3
set theContents to source of document 1.0
end tell
So, it would appear that scripting the browser might be more effective
for some tasks.
Charles
On Jan 21, 2004, at 1:21 PM, Christopher Nebel wrote:
On Jan 21, 2004, at 9:37 AM, Florian Weber wrote:
does anybody know of some information about what you
can do with applescript and browsers? for example is
netscape 4 and mozilla controllable with apple script? can
i make them open special urls via applescript? can figure
out if a page is fully loaded?
Of course, any discussion of scripting browsers would be incomplete
without mentioning 'do shell script "curl ..."', which is far more
effective for many Web tasks -- it just returns the page source as a
string. (Requires Mac OS X, naturally.)
--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.