|
|
#1 |
|
Applescript for saving webpage in Safari
Hi all,
A friend and I are making a simple AppleScript for automatically saving the current webpage in Safari. The twist is that the filename for the saved webpage is based on whatever text the user selects in the webpage (i.e. the title of a news article). Here is what we have so far: Code:
tell application "Safari" activate set the_url to URL of document 1 end tell tell application "System Events" tell process "Safari" click menu item "Copy" of menu "Edit" of menu bar 1 end tell end tell set the_filename to the clipboard set the_path to "'/Users/Roy/Documents/" & the_filename & ".html'" do shell script "curl -o " & the_path & " '" & the_url & "'" EDIT: Nevermind folks.... putting a delay between the copy command and setting the_filename to the clipboard did the trick! EDIT2: fwiw, we ended up using the save function in Safari directly... this produces an html file with a ".html.download" extension, so a shell script takes it back to ".html". I've got the script mapped to a function key and it's quite useful if you only save to a few directories regularly. Here's the final version: Code:
tell application "Safari" activate end tell tell application "System Events" tell process "Safari" click menu item "Copy" of menu "Edit" of menu bar 1 end tell end tell delay 1 set the_filename to (the clipboard) & ".html" set the_filepath to "Macintosh HD:Users:Roy:Documents:" & the_filename set the_shellfilepath to "'/Users/Roy/Documents/" & the_filename & ".download'" set the_shellfilepath2 to "'/Users/Roy/Documents/" & the_filename & "'" tell application "Safari" activate save document 1 in the_filepath end tell do shell script "mv " & the_shellfilepath & " " & the_shellfilepath2 Last edited by dolphin842; Nov 29, 2006 at 02:11 PM. Reason: figured it out |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| thread | Thread Starter | Forum | Replies | Last Post |
| which app is good for saving webpages for offline viewing? | chochoo | iPad | 1 | Mar 12, 2011 08:32 PM |
| Search within your own text on a webpage in Safari | funjoy | Mac Applications and Mac App Store | 1 | May 27, 2009 11:34 AM |
| 3g Iphone Wont Work In Load Webpages In Safari In 3g Mode | Prettyboyian | iPhone Tips, Help and Troubleshooting | 0 | Aug 26, 2008 08:52 AM |
| Problem saving webpages in Firefox3 (as html) | bsheridan | Mac Applications and Mac App Store | 8 | Aug 4, 2008 01:55 PM |
| Applescript for removing cookies in Safari... | iGary | Mac Applications and Mac App Store | 2 | Dec 14, 2004 04:14 PM |
All times are GMT -5. The time now is 07:17 PM.






Linear Mode

