htm to webarchive

Hi
i want a way to convert htm files to webarchive, but WITH pictures!
what i tried so far:

set targ_pt to (path to sites folder)
tell application "Finder" to set sel to the selection

repeat with i in sel
	set openy to false
	tell application "Finder" to if class of i is not folder then
		open i
		set openy to true
	end if
	if openy is true then
		tell application "Safari"
			activate
			tell application "System Events"
				keystroke "s" using command down
				keystroke return
			end tell
			--set nm to name of document 1
			--	save document 1 in (targ_pt as text) --as (nm & ".webarchive" as text)
		end tell
	end if
	--wait until the page are loadet
	delay 1
end repeat

i’m really unhappy with this script.

You can use the command line utility textutil. It should work with images.

set textutilPath to "/usr/bin/textutil"

-- get the input html file and variables
set htmlFile to choose file with prompt "Choose the HTML file to convert to WebArchive:" without invisibles

-- calculate the output webarchive path
set webarchivePath to (htmlFile as text) & ".webarchive"

-- convert html to webarchive
do shell script quoted form of textutilPath & " -format html -convert webarchive -output " & quoted form of POSIX path of webarchivePath & space & quoted form of POSIX path of htmlFile

Yee!!
:smiley:
great, regulus6633