The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniWeb > OmniWeb General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
how to reference the source for an OmniWeb page via AppleScript Thread Tools Search this Thread Display Modes
I am trying to make an AppleScript to open the HTML source for the current browser tab into BBEdit.

Safari has a property named "source" within the class "document", but I cannot find a similar reference within the OmniWeb properties to the "browser" or "tab" classes. (I am reading through the OmniWeb AppleScript dictionary from the Script Editor.)

By using the "source" property for a Safari document, I can get this to work with this reference:

set safariSource to the source of document 1 as string

Does anyone know if the same kind of thing is possible within OmniWeb?

Thanks,

Rob Johnson
 
Quote:
Originally Posted by eYeToEyeRob
IBy using the "source" property for a Safari document, I can get this to work with this reference:
Rob, it seems that OmniWeb does not give the source code for a loaded page via AppleScript directly. However, you can access the source yourself in various ways, since OmniWeb gives you the URL.

The simplest way is to get the address and use a "do shell script" command along with the command-line utility "curl" to get the file:

tell application "OmniWeb"
set pageAddress to address of active tab of browser 1
end tell
do shell script "curl " & quoted form of pageAddress


Another way that uses only OmniWeb is the following:

set downloadFilePath to ((path to desktop) as string) & "pagedownload.html"
tell application "OmniWeb"
set pageAddress to address of active tab of browser 1
OpenURL pageAddress to (POSIX path of downloadFilePath)
end tell


Neither way is ideal. OmniWeb should give access to the source as a property of the tab (NOT the browser, please - that's Safari's broken way of doing things - "there are no tabs in AppleScript").
 
We have a request for this in our database, thanks!
 
Quote:
Originally Posted by Krioni
set downloadFilePath to ((path to desktop) as string) & "pagedownload.html"
tell application "OmniWeb"
set pageAddress to address of active tab of browser 1
OpenURL pageAddress to (POSIX path of downloadFilePath)
end tell
Thanks, Krioni !

I couldn't get the OpenURL method to work on my system -- this line resulted in what looked to me like a file containing binary contents when opened with BBEdit:

OpenURL pageAddress to (POSIX path of downloadFilePath)

However, your curl tip did just what I wanted. Here's what I ended up with:

tell application "OmniWeb"
set owAddress to the address of the active tab of the browser of the active workspace
set owUrl to the first item of owAddress
set owSource to (do shell script "curl " & quoted form of owUrl)

tell application "BBEdit"
activate

if exists text window 1 then
make new text document at text window 1 with properties {contents:owSource, source language:"HTML"}
else
make new text window with properties {contents:owSource, source language:"HTML"}
end if
select insertion point before character 1 of text window 1

end tell

end tell

Until there's a formal OW reference, this will do fine...

Thanks again,

Rob

Last edited by eYeToEyeRob; 2006-06-30 at 09:39 PM.. Reason: To add Title
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
reference of result of duplicate command in applescript? ericscheid OmniGraffle General 1 2012-09-05 11:25 PM
Dynamically reference another canvas' page number? earleymw OmniGraffle General 0 2011-12-29 05:34 PM
Launching OmniWeb brings up recent page, not designated Home Page jwthomas OmniWeb General 14 2008-05-29 10:55 PM
PHP page type text/php displays as source PatriciaW OmniWeb General 5 2008-02-14 02:45 PM
Source Editor & Page Inspector andreas_g OmniWeb Feature Requests 1 2006-05-09 09:24 AM


All times are GMT -8. The time now is 02:40 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.