2024-02-01

Scraping/Extracting content from MacOS native apps using AppleScript and UI Browser

Downie is a video downloader for MacOS that supports close to 1000 websites. The full list of websites is only available in the app’s settings UI. Let’s extract/scrape them using AppleScript and UI Browser.

Desired result

10play.com.au
15min.lt
163.com
study.163.com
vod.126.net
17173.com
1tv.ru
...

Other possible use cases:

-- Use this script as a wrapper for GUI Scripting statements when you are confident that GUI Scripting is available and enabled or that the user knows how to enable it if necessary

activate application "Final Cut Pro"
tell application "System Events"
	tell process "Final Cut Pro"
		set imageTitles to {}
		repeat with i from 1 to 10
            set x to get title of image i of UI element 1 of scroll area 2 of splitter group 1 of group 1 of splitter group 1 of group 1 of splitter group 1 of group 1 of splitter group 1 of group 1 of splitter group 1 of window 2
			set end of imageTitles to x
		end repeatq
		return imageTitles
	end tell
end tell