Errors trying to script Opera 10

Hi all,

Am I doing something wrong with the Script below?

tell application "Opera 10"
	GetURL "http://www.google.com"
	set HTMLsource to GetSource
end tell

I see Opera has an Applescript Dictionary, and I thought I was using the syntax correctly. But, I keep getting errors thrown by Opera.

I would like to have a script collect the HTML source of a page. I’ve been using Opera as my browser of late, but if Opera can’t do it and another browser can, I’m open to changing browsers.

Thanks for any help!

You can get the source using curl…

set theURL to "http://www.google.com"
set theHTML to do shell script "curl " & quoted form of theURL

Curl is very flexible. Suppose you wanted to get the source into a file… you could do this:

set theURL to "http://www.google.com"
set outPath to (path to desktop as text) & "google.html"
set theHTML to do shell script "curl " & quoted form of theURL & " -o " & quoted form of POSIX path of outPath

Hi regulus6633,

Thank you for the idea. I had completely forgotten about curl.

I have a follow- up question, though. How could I use curl with a web browser to get the source of the page I’m currently viewing?

I would like to be able to trigger an Applescript to capture the HTML source of the page I’m viewing, and then save it to disk. I’m not sure how to rework the example you gave to do that, though. If you have any suggestions, I would greatly appreciate them.

Thank you for your help!

If you don’t mind using Safari…

tell application "Safari"
	tell current tab of window 1
		set theSource to source
	end tell
end tell

-- or

tell application "Safari"
	tell current tab of window 1
		set theURl to URL
	end tell
end tell

I don’t mind using Safari at all. Thanks for your help!