Safari and "save as source"

Hi all.
I’m writing an AppleScript that open a URL on Safari, and save the source of the page as a txt file.

This is my try

tell application "Safari"
		open location "http://www.apple.com/index.html"
		delay 10
		save window document 1 as source
	end tell

Script works fine until saving document, where it gives me an error.

What is the right sintax for save a page with source?

NB: I can use another browser like Camino, Firefox, opera or other, if AS support is better.

The only way to go:

set SafSrc to do shell script "curl http://www.apple.com/index.html > ~/desktop/Site_Source"

To read it without interpretation (which TextEdit will do), you’ll have to open it as text in TextWrangler for example. the variable SafSrc also has the source in it if you want to do something to it (like find a particular phrase).

That’s perfect, tankx very much.
So, that I have to do is to pass the content to BBEdit (or open it with BBEdit, is the same, I think)

That’s i wrote

on run
set SafSrc to do shell script "curl http://www.apple.com/index.html > ~/desktop/Site_Source > ~/desktop/Site_Source.txt"
tell application "BBEdit"
open document file "Site_Source.txt" of folder "Desktop" of folder "matteo" of folder "Users" of startup disk
				tell window 1 of application "BBEdit"
(...)
end tell
				close window 1 saving yes
end tell

But it give me an error in the row “open document file…”

What wrong?

The script works perfect!

This part is ending. I have some problem with another part (http://bbs.applescript.net/viewtopic.php?pid=72895#p72895) with BBEdit.

Thanks a lot for the patience.