Search current webpage for phrase
Hi there, I'm trying to write an Apple script to search the currently open tab in Safari for 2 phrases, "free" & "bonus". I just want to search the parsed HTML, not the code itself. Any ideas how to do this?
Hi there, I'm trying to write an Apple script to search the currently open tab in Safari for 2 phrases, "free" & "bonus". I just want to search the parsed HTML, not the code itself. Any ideas how to do this?
Something to get you started. Tested on El Capitan 10.11.1, using different keywords for tested website.
set word1 to "free"
set word2 to "bonus"
tell application "Safari"
activate
tell current tab of front window
set tabContent to text of it
if word1 is in tabContent and word2 is in tabContent then
display dialog "Found both " & word1 & " and " & word2
else if word1 is in tabContent then
display dialog "Found " & word1
else if word2 is in tabContent then
display dialog "Found " & word2
else
display dialog "Found neither " & word1 & " and " & word2
end if
end tell
end tell
Amazing, thank you Viking OSX! ✅
Search current webpage for phrase