1
私はデスクトップの背景をその日の最新のNASAイメージに設定するためにAppleScriptを書こうとしています。私はこのRSSフィードを使用してこれをしようとしています:https://www.nasa.gov/rss/dyn/lg_image_of_the_day.rssAppleScriptでRSSを解析する(grep?を使用)
パズルの最後の部分は、RSSフィードからイメージのURLを解析しています。私はこれがgrepを使って非常に可能であるべきだと考えていますが、grepの使い方はわかりません。私はフィードを見て、私は最初の<item>
の最初の<link>
になりたいと思っています。
set {year:y, month:m, day:d} to (current date)
set todaydate to d & "\\ " & m & "\\ " & y
log todaydate
set myFile to "/Users/me/Pictures/NASA\\ Image\\ of\\ the\\ Day/" & todaydate & ".jpg"
property RSSURL : "https://www.nasa.gov/rss/dyn/lg_image_of_the_day.rss"
--get the first download link from the rss feed
--ie stuff inside <link> </link> directly after first <item>
set pictureURL to "" --but to the right thing, of course
do shell script "curl -o " & myFile & " " & pictureURL
tell application "Finder" to set desktop picture to POSIX file "myFile"
グレープマークアップは厄介で間違っています。システムイベントのXML Suiteを参照してください。参照で関連する値を抽出できるはずです。 – foo