¿Cómo puedo utilizar Applescript Y Safari para extraer la respuesta de este sitio: http://www.wolframalpha.com/input/?i=whats+las+significado+de+la vida%3F
Estoy intentando extraer la respuesta en replicable de texto simple. Que es, .txt
formato.
Me sale este error:
"Can't make text items 2 thru -1 of "missing value" into type text.
Cuando la aplicación de la siguiente secuencia de comandos:
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>")