Re: saving displayed text on a web page as rtf
Re: saving displayed text on a web page as rtf
- Subject: Re: saving displayed text on a web page as rtf
- From: Simon Forster <email@hidden>
- Date: Thu, 04 Jul 2013 16:32:20 +0100
On 4 Jul 2013, at 13:23, 2551 <email@hidden> wrote:
> Any other thoughts? Anyone?
Can you just print the page to PDF?
Oh why do I get sucked down these rabbit holes?
(Answer: 'Cause it's more interesting than work)
Anyway, if you'e happy to save as a PDF, the following seems to work on my machine.
HTH
Simon
-- Folder blah needs to exist
set saveFolder to ((path to desktop folder) as string) & "blah" as alias
set saveName to (do shell script "date +%Y-%m-%d_%H.%M.%S") & ".pdf"
-- You need to open a page in Safari
-- This just makes sure the page is fully loaded
tell application "Safari"
tell document 1
-- Delay until page loaded
repeat until (do JavaScript "document.readyState") is "complete"
delay 0.2
end repeat
end tell
end tell
-- Print to PDF
tell application "System Events"
set frontmost of process "Safari" to true
tell process "Safari"
keystroke "p" using command down
tell front window
repeat until exists sheet 1
delay 0.02
end repeat
tell sheet 1 -- Print dialog
click menu button "PDF"
repeat until exists menu 1 of menu button "PDF"
delay 0.02
end repeat
click menu item "Save as PDF…" of menu 1 of menu button "PDF"
repeat until exists sheet 1
delay 0.2
end repeat
tell sheet 1 -- "Save as…" dialog
-- Open "Go to folder" dialog
keystroke "g" using {command down, shift down}
repeat until exists sheet 1
delay 0.2
end repeat
tell sheet 1 -- "Go to folder:" dialog
-- Set folder path
set value of text field 1 to (POSIX path of saveFolder) as string
click button "Go"
repeat while exists sheet 1
delay 0.2
end repeat
end tell -- End of "Go to folder:" dialog
set value of text field 1 to saveName
click button "Save"
end tell -- End of "Save as…" dialog
end tell
end tell
end tell
end tell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden