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

16 Replies, 1006 Views

Yo, I feel you! AppleScript HTML DOM download images can be tricky at first. Honestly, I’d recommend using a tool like `Puppeteer` or `BeautifulSoup` if you’re open to alternatives. They’re way more flexible for scraping images.

But if you’re set on AppleScript, try this:

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

This stores all image URLs in a list. You can loop through and download them using `curl` or something.

Messages In This Thread



Users browsing this thread: 1 Guest(s)