Come posso utilizzare Applescript And Safari per estrarre la risposta da questo sito: link
Sto tentando di estrarre la risposta in testo in chiaro copiato. Ovvero, .txt
format.
Ho ricevuto questo errore:
"Can’t make text items 2 thru -1 of "missing value" into type text.
Quando si implementa il seguente script:
to getInputByClass(theClass, num)
tell application "Safari"
set input to do JavaScript "
document.getElementsByClassName('" & theClass & "')[" & num & "].innerHTML;" in document 1
end tell
return input
end getInputByClass
to extractText(searchText, startText2, endText)
set tid to AppleScript's text item delimiters
set startText1 to "x"
set searchText to ("x" & searchText)
set AppleScript's text item delimiters to startText1
set endItems to text item -1 of searchText
set AppleScript's text item delimiters to endText
set beginningToEnd to text item 1 of endItems
set AppleScript's text item delimiters to startText2
set finalText to (text items 2 thru -1 of beginningToEnd) as text
set AppleScript's text item delimiters to tid
return finalText
end extractText
getInputByClass("popup ui-draggable", 0)
set theText to getInputByClass("r", 0)
set theResult to extractText(theText, "<pre>", "</pre>")