Re: Open URL in Safari with Post params
Re: Open URL in Safari with Post params
- Subject: Re: Open URL in Safari with Post params
- From: Simon Forster <email@hidden>
- Date: Fri, 11 Nov 2011 16:17:46 +0000
On 11 Nov 2011, at 10:15, Thomas Fischer wrote:
> I wouldn't know how to do this directly, but you can download a file and open it in Safari
Hi Thomas
Thanks for the reply but not what I'm after.
If a web page has a simple form asking for your name such that the source code for the form looked like:
<form method="POST" action="/example.cgi">
<input type=text name="birthyear">
<input type=submit name="press" value=" OK ">
</form>
Using curl I could fake submitting data using the form by calling:
curl --data "name=Thomas" http://www.example.com/example.cgi
I'd like to do the same thing but using Safari.
As Emmanuel pointed out, some CGIs will not care too much whether the data is sent via POST or GET. If this is the case, I can ask Safari to open http://www.example.com/example.cgi?name=Thomas.
However, the CGI I've got to interact with does make the distinction between POST and GET data so this route is not open to me.
At the moment I've got to download the form in Safari, fill it in (programmatically) and then submit the form. This seems somewhat inelegant and a (small) waste of my time as I've got to wait for the page with the form in to be downloaded before I can fill it in. Far better to make the call directly to the CGI with the POST data from the off - except there doesn't seem to be a method to do this.
In pseudo-code what I'm after is:
tell application "Safari"
activate
tell window 1 to set current tab to make new tab
set the URL of document 1 to "http://www.example.com/example.cgi" using post data "name=Thomas"
end tell
Simon _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden