I am trying to port a custom PC program over to Mac using AppleScript. Most of the program is web based and only the front end is OS specific. The PC version uses a hidden web browser window to transfer queries to the server in the format mydomain.com/database?query.
I can open a regular browser window in applescript using “open location mydomain.com/database?query” and this works fine except the info returned is a long strings of unformatted text that need to be parsed & formatted by the rest of the program to be useful. So the above browser window is just gibberish and useless to the user.
I am looking for some way to create a hidden invisible browser instance like I do on the Windows side.
Thanks
Try something like this:
-- put the url together before hand, if you want
do shell script "/usr/bin/curl " & quoted form of ("http://example.com/database?query")
set example to result
-- parse and format as needed
Thanks for your reply.
How does "do shell script "/usr/bin/curl " & quoted form of ("http://example.com/database?query")" invoke a browser instance?
When I try above example with real URL I get a “No such file or directory error”
I can’t help you with that without seeing any code.
It doesn’t.
See also: cURL
Examples:
do shell script "/usr/bin/curl " & quoted form of ("http://bbs.macscripter.net/viewtopic.php?id=26669")
set example to result
do shell script "/usr/bin/curl --silent --show-error " & quoted form of ("http://bbs.macscripter.net/viewtopic.php?id=26669") & ¬
" | /usr/bin/grep --only-matching '<a href=\"profile.php?id=[0-9]\\+\">[^<]\\+</a>'" & ¬
" | /usr/bin/sed -e 's/<a href=\"profile\\.php\\?id=[0-9]*\">//g' -e 's/<\\/a>//g'"
set example to paragraphs of result
While I was waiting for a reply I learned about curl, didnt know about it previously.
I got you code working without the path just curl & quoted form of ("http://example.com/database?query")"
Thanks again. This is a good start to my project.