Is there a way to get gif’s or jpegs from a webpage besides taking a picture and cropping it.
I would like to get the original image like dragging it to my desktop off the browser.
Are you talking about images that you can’t drag and drop, images like the MacScripter logo in the top left?
If so, go into the source of the webpage, find the URL and put it in your address bar. It will take you right to it and from there you can drag and drop.
you can try something like this:
-- make a list of all image source links by executing javascript in Safari:
set imgList to {}
tell application "Safari"
set the imgCount to (do JavaScript "document.images.length" in document 1)
repeat with i from 0 to (the imgCount - 1)
set imgLink to (do JavaScript "document.images[" & (i as string) & "].src" in document 1)
copy imgLink to the end of imgList
end repeat
end tell
-- download all images using the shell command 'curl'
repeat with imgLink in imgList
try
(do shell script ("cd ~/Desktop/; curl -O " & quoted form of imgLink))
end try
end repeat
I put my Safari download images method in code exchange, just now. See here hope its a winner. I do a lot of image downloads and naming conflicts, 31 character limit, format types, then tidy place to put them. I do a chest on desktop, site domain name folder, time stamp folder. Check out my more advanced again one.
Hope this helps
i posted this message in reply to the above link to the code exchange, but added here as well in case it was in the wrong place <<
hi,
this is really useful. i would like to modify it slightly, if possible, to achieve the following:
-
the url that the images come from is in the script. i.e. safari doesnt need to be open (i have an example where a script collects text when safari is closed, but not images). so replacing ‘document 1’ with something? if this can’t be done it’s not a massive problem, but i would ideally like to source images from maybe 5 urls, so can it be altered to include ‘document 2’ etc?
-
the script runs every 5 minutes or so, so that if a page is updated with new images, it can keep collecting them automatically. i’d probably have the script as an application that is always open in the background.
-
for what i need to achieve, i’d like the images to be saved to a designated folder on the desktop (called ‘images’ for example), and rather than creating a new folder for each time it collects the images, i was hoping the images could just be added to that ‘images’ folder each time, without sub-folder etc? i know that would cause a headache with repeating file names for those images that aren’t updated on the url, so i was wondering if applescript could delete the files already in the folder a few seconds before it adds the new ones? i would then use automator as a folder action to number the jpegs as 0.jpg, 1.jpg 2.jpg etc for what i need to do with them.
i dare say a lot of this can’t be done simply, and as i’m inexperienced with applescript, some tips would be great (im not expecting anyone to post the whole code, im not that cheeky!)!! im kind of half way to achieving an interesting new media installation piece whereby news headlines/stories are re-presented as a kind of filmic narrative - i have got the script working to source the headlines from rss feeds into the programming software i’m using, i’m now hoping that i can figure out how to download the images and use those!!
thanks very much,
james