¿Cómo puedo usar Applescript And Safari para extraer la respuesta de este sitio? enlace
Estoy intentando extraer la respuesta en texto plano copiable. Es decir, formato .txt
.
Recibo este error:
"Can’t make text items 2 thru -1 of "missing value" into type text.
Al implementar el siguiente 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>")