How can I use AppleScript and HTML DOM to download images from a webpage?

16 Replies, 1143 Views

Hey there! I’ve been tinkering with AppleScript HTML DOM download images for a while now. It’s a bit of a niche use case, but it’s doable. Here’s a quick script to grab image URLs:

```applescript
tell application "Safari"
set imgURLs to do JavaScript "Array.from(document.images).map(img => img.src);" in document 1
end tell
```

Once you have the URLs, you can use `curl` or `wget` to download them. If you’re dealing with a lot of images, consider batching the downloads to avoid timeouts.

Also, this forum thread has some great tips: [link].

Messages In This Thread



Users browsing this thread: 1 Guest(s)