Hithere,
我使用AppleScript抓取safari中的文字, 我现在使用我的脚本一个月,但是因为有几天我对一个变量有一些困难,给我这个结果:
5class ="名称"> 3class ="名称"> 0class ="名称"&→6
而不是
5306
这是脚本
set PhoneFormat to missing value
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
getInputByClass("field phone", 0)
set theText to Unicode text
set theSource to getInputByClass("field phone", 0) as string
property leftEdge4545 : "tel:"
property rightEdge4545 : "\">"
set saveTID to text item delimiters
set text item delimiters to leftEdge4545
set classValue to text item 2 of theSource
set text item delimiters to rightEdge4545
set PhoneFormat to text item 1 of classValue
set text item delimiters to saveTID
PhoneFormat
set the_phone_number to PhoneFormat
set the_last_three to characters -4 thru -1 of the_phone_number as string