Created
June 20, 2014 07:08
-
-
Save cmittendorf/dafc953b3425f523a8a7 to your computer and use it in GitHub Desktop.
Retrieve the text content of the current web page from Safari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# prepared for Yosemite (10.10) | |
# osascript -l JavaScript -e "Application('Safari').documents()[0].text()" | |
CONTENT=$(osascript -ss << EOF | |
tell application "Safari" | |
tell its first document | |
get its text | |
end tell | |
end tell | |
EOF) | |
# remove the first character | |
CONTENT="${CONTENT:1}" | |
# remove the last character | |
CONTENT="${CONTENT%?}" | |
echo "${CONTENT}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment