Applescript:从网站获取信息

问题描述 投票:0回答:1

试图从这个网站(https://songbpm.com/one-of-these-nights-eagles)获取一点信息,作为AppleScript的一部分,在iTunes的每个曲目上自动填充BPM。该脚本接受跟踪,打开网页,现在我只需要列出第一个BPM(在本例中为110)并将其发送回我的脚本。

我该怎么做呢?

applescript itunes
1个回答
0
投票

使用这段代码计算出来,完全归功于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)
© www.soinside.com 2019 - 2024. All rights reserved.