Capturing text on a Safari web page

I’d like to begin my first Applescript project.

The goal is to capture text on a Safari web page that has been selected, write it to a Simpletext file along with the URL for that page. When the script is started, a choice would be given to create a new file or append it to the last file used, and a choice to include the URL or not. For example for this page I selected the top area of the page. The Simpletext file would have an entry of :

MacScripter BBS | Applescript Forums
Scripting Forum

�FAQ� �Search� �Memberlist� �Usergroups�

�Profile� �You have no new messages� �Log out [ hkhamilton ]�

Any ideas as to if or how this could be done?

See these links:


Thanks Jon

I tried the “Safari Selection to Script Editor” script and changed the Scrip Editor application line to Textedit. Ran the script and a new Textedit file opened but may selection in Safari or the URL did not paste in. I quess I’ll need to learn some Applescript. I’m running OS 10.2.8, Applescript 1.9., Script Editor 1.9, Text Edit 1.2.

i don’t have a million bucks so any wisdom you can extend would be greatly and thankfully appreciated.


The Safari selection scripts were just to illustrate how to grab the selection and the URL. The second two links show how to save that content to a file without the use of any other application. As it says in those links, many new scripters don’t realize that you can create, read, & write files all from AppleScript. Combining the scripts to grab the content & URL then then use the code from the other links (either one, really) to write that data to a file.