Skip to content

Instantly share code, notes, and snippets.

Created May 31, 2013 20:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save anonymous/5687755 to your computer and use it in GitHub Desktop.
Save anonymous/5687755 to your computer and use it in GitHub Desktop.
Script that pulls URLs from a page in Safari and writes to a text file on the Desktop.
-- Get the text from Safari
tell application "Safari"
set thePageText to text of document 1
end tell
-- Split the text into paragraphs
set thePars to paragraphs of thePageText
-- Find all paragraphs matching the desired criteria
set theText to ""
repeat with aPar in thePars
if aPar contains "www.myrepospace.com/profile" then
set theText to theText & (aPar & return as string)
end if
end repeat
-- Write the paragraphs to a file on the Desktop
set theOutputFile to (path to desktop folder as string) & "Results.txt"
try
set theOutputFile to open for access theOutputFile with write permission
write theText to theOutputFile starting at eof
close access theOutputFile
on error
close access theOutputFile
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment