0

次のスクリプトを機能させるのに苦労しています。つまり、スクリプトのタイマーを設定して、picture-0001.jpg から picture-xxxx までの継続的なファイル名で www.url.com/picture.aspx の jpg バージョンを HDD に保存したいと考えています。 .jpg。

set {tUrl, dFolder} to {"www.url.com/picture.aspx", "~/Desktop/curlDownload/"}

set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set fName to (last text item of tUrl) as string
set AppleScript's text item delimiters to oAStid

do shell script ("mkdir -p " & dFolder & "; curl -A/--user-agent " & tUrl & " >> " & (dFolder & fName))

ご協力いただきありがとうございます。

4

1 に答える 1

0

curl を使用して Web サイトのスクリーンショットを保存することはできません。Homebrewをインストールしてから webkit2pngを でインストールできbrew install webkit2pngます。

cron でスクリプトをスケジュールする方が簡単かもしれません。EDITOR=nano crontab -ecrontab を編集して次のような行を追加することで、1 分おきに実行できます。

*/2 * * * * webkit2png -C -s 1 -W 1000 -H 1000 --clipwidth 1000 --clipheight 1000 http://stackoverflow.com -o ~/Desktop/$(date '+\%y\%m\%d\%H\%M\%S').png

(質問を誤解していて、実際に画像をダウンロードしようとしている場合はcurl -O https://stackoverflow.design/assets/img/logos/so/logo-stackoverflow.png、同じファイル名でファイルを現在のディレクトリに保存するようなものです。)

于 2012-07-03T04:09:46.033 に答える