AppleScript script to save a Safari page as the web-archive fails
I worked out the following script:
tell application "Safari"
set theWebContent to document 1
set theName to name of current tab of window 1
set theExtension to ".webarchive"
save theWebContent in POSIX file (POSIX path of file (((path to desktop) as text) & theName & theExtension))
end tell
It worked only couple of times then started choking with Safari pulling a drop-down alert dialog telling it was unable to save the contents of the tab as a web-archive. What do I miss?
There're some complex examples of saving as the web-archive involving scripting objects. Could we do without such complexity?