My intention is to grab the image that is generated and returned in the URL, ideally without having to open a browser. For example the script below will always output a link with one image on it. Automator has a way to download urls which in turn throws the resulting image file in a destination folder. Surely there must be a way for Applescript to do this? Can anybody give me any advice or maybe a post that I cannot find?
set the theRes to "300"
display dialog "URL?" default answer "http://www.google.com"
set the theURL to the text returned of the result
set input to "http://chart.apis.google.com/chart?cht=qr&chs=" & theRes & "x" & theRes & "&chl=" & theURL
return input
If I got you right, something like the following should do:
set the theRes to "300"
display dialog "URL?" default answer "http://www.google.com"
set the theURL to the text returned of the result
set input to "http://chart.apis.google.com/chart?cht=qr&chs=" & theRes & "x" & theRes & "&chl=" & theURL
set input to quoted form of input
set temp_file to (path to temporary items)
set temp_name to do shell script "uuidgen"
set temp_file to (POSIX path of temp_file) & temp_name
set q_temp_file to quoted form of temp_file
set cmd to "curl -o " & q_temp_file & " " & input
do shell script cmd
set x to alias (POSIX file temp_file)
tell application "Finder" to open x
This creates some unique name, saves the file into the temporary items folder and tells the Finder to open that file. Change that “tell application “Finder”” to whatever you need here.