how does one use 'post' parameter on "download url&quot

hello all,

I’m trying to download a url by posting information to a website using applescript. Does anyone understand how to submit a “key value pair” as devonthink pro describes it in its dictionary?

I want to do something like

tell application “devonthink pro”
set x to set new_source to download “” post {hl, “test search to google”}
end tell

but that seems to only generate an error. Does anyone understand the format of how the “key-value” pairs after the post parameter is supposed to be formatted?

Any help much appreciated.



Google doesn’t use HTTP POST but here’s an example querying MacNN for DEVONthink:

tell application "DEVONthink Pro"
	set theURL to ""
	set thePost to {|path|:"DEVONthink", |Go|:"Submit"}
	set theHTML to download markup from theURL post thePost
	create record with {name:"MacNN Search", type:html, source:theHTML, URL:theURL}
end tell

Note: The enclosing | characters are necessary to prevent AppleScript from interpreting them as commands/properties.

That is very cool. Could some standard search scripts be included with the next release of DTP? Here’s a suggestion:
Have the script use any selected text from DTP, submit the query to some source (i.e. apple, macupdate, wikipedia, etc.; maybe a pulldown list) and return a new window with the search results. Having the results returned to a new window is KEY, since there is not a tabbed browser in DTP.

Once again, thank you for the help Christian.

That’s quite unlikely as DEVONagent does exactly this.

Yes, but that’s like catching a butterfly with a sledge hammer. It is way over kill. For example, if I am browsing in DTP and select the word butterfly and choose search in DevonAgent. It transfers me to DA. I then choose to search with Google. I then wait for 30-60 seconds for DA to bring back all the Google results just to find out what butterfly means. I realize that I can change the settings for the search to take less time, but that means I have to change them back when I want to really take advantage of the power of DA. I don’t know about other users, but I still use my google search box in safari rather than DA for everyday stuff. I think that a simple internet search feature in DTP would be very useful. IMHO.


This is great…I was able to use the post command in order to script through an automatic login process that my university requires me to do from time to time. I now have a subroutine that can detect when the proxy redirect has thrown up its login page, pull the keys for logging in from my keychain, post my login credentials, download the intermediate page (which basically tells me I entered my password correctly), and finally let devon think get a web archive of the original destination page. It works, by the way, with https: as well. I can post sample code if anyone is interested. Thanks again, Christian!

By the way christian, it is sooooo nifty that all the applescripts now automatically use the cookies & proxies of the system and webkit. I can’t tell you how much trouble that saves me, and how many more things are now scriptable. I’m sure that was a big deal to revise, but it IS noticable.

One last thing: Is there any chance of making an Application level variable that DTPro would remember the ultimate URL of the last "download URL/download markup " command. Sometimes re-directs happen, whether through proxy redirection or through redirect tags. It would be nice if there were simply an applescript variable that one could check (something like “last downloaded page”) that had that info so one could apply a post command to a page that was fetched via “download markup”. As it is right now, I can end up with the source code or a web-archive for a page without knowing its true url, which is, as I suggest, very bad if one wants to POST off of it.



The next release will include a “last downloaded URL” property.


Once again, this is tremendous! It’s so nice for you to be willing to add little things like this. I have a number of scripts that can be completely overhauled once I have that magical property of the last URL. I know, certainly, that not having to open a browser window in order to get the final url will be more elegant, but it will probably be considerably faster, too.