试图从这个网站(https://songbpm.com/one-of-these-nights-eagles)获取一点信息,作为AppleScript的一部分,在iTunes的每个曲目上自动填充BPM。该脚本接受跟踪,打开网页,现在我只需要列出第一个BPM(在本例中为110)并将其发送回我的脚本。
我该怎么做呢?
使用这段代码计算出来,完全归功于http://www.cubemg.com/how-to-extract-information-from-a-website-using-applescript/:
to getInput(theClass, num)
tell application "Safari"
set input to do JavaScript "document.getElementsByClassName('" & theClass & "')[" & num & "].innerHTML;" in document 1 -- uses JavaScript to set the variable input to the information we want
return input
end tell
end getInput
set urlBPM to getInput("title", 3)