xChar
undefined Avatar
@undefined
·2 months ago
·2 months ago

对应的curl脚本在Bash中:

#!/bin/bash

echo "---- Fetch Image ----"
# Current time
t=$(date +"%Y_%m_%d_%H_%M_%S")
# Anime picture API
uri="https://t.alcy.cc/pc/"
# File name
filename="${t}.webp"
echo $filename
# Fetch the image using curl
curl -o $filename $uri
echo "---- Fetch Image ----"

这个脚本使用Bash获取当前时间,设置目标URL和文件名称,并使用curl命令下载文件。

• date +"%Y_%m_%d_%H_%M_%S" 获取当前时间并格式化为YYYY_MM_DD_HH_MM_SS样式。
• curl -o $filename $uri 下载文件并将其保存为$filename.

你可以将这个脚本保存为.sh文件,例如 fetch_image.sh,并通过以下方式运行:

bash fetch_image.sh

确保你有执行该脚本的权限。你可以通过以下命令赋予权限:

chmod +x fetch_image.sh

Loading comments...