Here is an applescript solution for grabbing the html code from a page online. This is particularly handy if you are trying to grab the code from a page that you need to login to. I am sure there is a much better solution out there, but this one seems to work for me ok.
CODE:
-
-- Define the page to save the document and the url
-
set the pageFile to "/Users/yourUserNameHere/Desktop/safariSource.html"
-
set the pageUrl to "http://www.plasticstare.com/"
-
-
-- define the applescript to run
-
-
tell application "Safari"
-
activate
-
make new document at end of documents
-
set URL of document 1 to pageUrl
-
end tell
-
-
set web_page_is_loaded to false
-
--check if page has loaded
-
repeat
-
delay 0.5
-
tell application "System Events" to tell application process "Safari"
-
if (name of static text 1 of group 1 of window 1 as text) begins with "Contacting" or (name of static text 1 of group 1 of window 1 as text) begins with "Loading" then
-
-- do nothing
-
else
-
exit repeat
-
end if
-
end tell
-
end repeat
-
-
tell application "Safari"
-
set siteSource to the source of document 1 as text
-
set theFile to open for access (pageFile) as POSIX file with write permission
-
set eof of theFile to 0
-
write siteSource to theFile
-
close access theFile
-
end tell





