且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

AppleScript删除两个字符串之间的所有文本

更新时间:2023-11-23 08:08:22

您可以使用shell逐行获取所有歌曲名称的列表(这不是AppleScript列表).

You could use the shell to get a list with all song names line by line (this is not a AppleScript list).

set charts to (do shell script "
curl -s 'https://www.apple.com/itunes/charts/songs/'| tr '\"' '\n' |awk '/^ alt=$/ {getline;print}'")

tr '\"' '\n'用新行替换双引号(tr手册页)

tr '\"' '\n' substitutes the double quotes with new lines (tr manual page)

awk '/^ alt=$/ {getline;print}'alt=行之后打印写有歌曲名称的行( awk手册页面)

awk '/^ alt=$/ {getline;print}' prints the line after the line alt= where the song name is written (awk manual page)