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

16 Replies, 1144 Views

Hey! I’ve been in your shoes before. AppleScript HTML DOM download images is a bit of a headache, but it’s possible. Here’s a quick script to get you started:

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

Then, use `do shell script` to download the images. If you’re stuck, this guide might help: [link].

Also, if you’re open to alternatives, `Puppeteer` is way easier for this kind of thing.

Messages In This Thread



Users browsing this thread: 1 Guest(s)