Skip to content

Instantly share code, notes, and snippets.

@JT5D
Forked from anonymous/WebScraper.applescript
Created July 14, 2013 04:41
Show Gist options
  • Save JT5D/5993234 to your computer and use it in GitHub Desktop.
Save JT5D/5993234 to your computer and use it in GitHub 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