Hey Everyone! I am looking for assistance on making a script that can go out to a website and grab a certain picture off of it and save it on my desktop. Is that possible? Here is the situation: I have a favorite web comic and I would like to be able to just run a script to go get the comic and save it so I can have an archive of the comic. Thanks for any help coming my way!
Here’s a modified version of what I use…
on run
(* The url to get the image from *)
set theImageUrl to "http://the.website.com/subdirectory/jobu.gif"
(* The name to save the image as *)
set ODel to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set theImageName to (text item -1 of (theImageUrl as string) as list) as string
set AppleScript's text item delimiters to ODel
(* Where to save the image *)
set desktopPath to (path to desktop) as string
set targetPath to (POSIX path of ((desktopPath & theImageName) as string))
set targetPath to ("'" & targetPath & "'") as string --> In case a space gets in there
(* Get the image using curl *)
try
set theCurlCommand to ("curl -o " & targetPath & " " & theImageUrl)
do shell script theCurlCommand
set DLStatus to "File downloaded successfully!"
on error
set DLStatus to "File could not be downloaded!"
end try
(* Display the status *)
display dialog DLStatus
end run
j
Hi Jobu
I wrote an application doing this. It’s called Picture Sucker and you may download a demo from my web-site (link below).
But, much more interesting, I made the source of an earlier release public here at Macscripter.net.
Simply search for “SING” in the Script Builders section and you may find the readable source. (It’s a GNU license, please respect it if you use code from the script and give credits).
This should help you further.
Good Luck,
Thomas