AppleScript 从 HTTP 服务器下载文件,改变 URL?

发布于 2024-09-29 03:44:02 字数 791 浏览 3 评论 0原文

我从来没有搞乱过 AppleScript,所以这对我来说只是一个概念。这可以吗?

游戏设计师 Bungie 在系统命名的文件和目录中托管了大量 Halo Reach 的 PNG 文件。 IE:

http://www.bungie.net/images/reachstats/commendations /onyx/onyx_large_ precision_multiplayer.png

更改同一单词的两个实例,并生成图像的另一个版本。将“onyx”更改为“铁”、“青铜”、“银”或“金”,您将获得相应的图像,如下所示:

http://www.bungie.net/images/reachstats/commendations/gold/gold_large_ precision_multiplayer.png

AppleScript 是否能够获取输入 URL,查找并更改 URL 中单词的实例,然后将关联的文件下载到目录中?今天是我的生日(10 月 27 日!因此是 XXVII),如果这能成功,如果有人能做到这一点,我会非常兴奋!

感谢您的热情解答!

I've never messed with AppleScript so this is only a concept to me. Can this work?

Bungie, the game designer, is hosting a ton of PNGs for Halo Reach in systematically named files and directories. IE:

http://www.bungie.net/images/reachstats/commendations/onyx/onyx_large_precision_multiplayer.png

Change two instances of the same word, and you generate another version of the image. Change "onyx" to "iron", "bronze", "silver" or "gold" and you get a corresponding image, like so:

http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png

Would an AppleScript be able to take an input URL, find and change the instances of the words in the URL, and then download the associated file to a directory? Today is my birthday (Oct 27th! hence the XXVII) and if this will work I would be super excited if someone could make this!

Thanks for all of your kind answers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤檠 2024-10-06 03:44:03

这是有效的:

set the destination_file to ((path to desktop as string) & "picture.jpg") as file specification
set thisImageSRC to "http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png"
tell application "URL Access Scripting"
    download thisImageSRC to destination_file replacing yes
end tell

字符串操作完全通过更改 Applescript 的文本项分隔符来完成。因此,要将 URL 的组成部分放入列表中,您需要执行以下操作:

set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set theUrlComponents to (every text item of theURL) as list
set AppleScript's text item delimiters to oldDelims

加盐调味,但我同意第一个评论者的观点,即有更好的语言可以做到这一点。 Applescript 将是我最后的选择。

This works:

set the destination_file to ((path to desktop as string) & "picture.jpg") as file specification
set thisImageSRC to "http://www.bungie.net/images/reachstats/commendations/gold/gold_large_precision_multiplayer.png"
tell application "URL Access Scripting"
    download thisImageSRC to destination_file replacing yes
end tell

String manipulation is done completely with changing Applescript's text item delimiters. So to get the components of the URL into a list, you need to do the following:

set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set theUrlComponents to (every text item of theURL) as list
set AppleScript's text item delimiters to oldDelims

Add salt to taste, but I agree with the first commenter that there are better languages to do this. Applescript would be my last choice here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文