Come faccio a scaricare un URL usando Applescript

1

Ero abituato a scaricare URL da un file Applescript, ma ho perso Applescript. Voglio inserire un URL: es .: "http://wpclassic.com/go.php?http://www.revolutiontwo.com/download/tv.zip" e chiedergli un posto dove mettere il file.

    
posta daviesgeek 08.08.2011 - 21:03
fonte

1 risposta

5
set the URLs to the text returned of (display dialog "Enter the URLs you would like to download. If you have more than one, separate them with commas please:" default answer "")
set the destination to (choose folder with prompt "Choose the folder you want to download the URLs to:")
set AppleScript's text item delimiters to ","
repeat with this_URL in the URLs
    tell application "URL Access Scripting" to download this_URL to the destination with progress and unpacking
end repeat
set AppleScript's text item delimiters to ""

Se utilizzi Lion, il codice sopra riportato non funzionerà (Apple ha rimosso URL Access Scripting per qualche motivo). Usa invece il comando di shell curl , come mostrato di seguito:

set the URLs to the text returned of (display dialog "Enter the URLs you would like to download. If you have more than one, separate them with commas please:" default answer "")
set the destination to (choose folder with prompt "Choose the folder you want to download the URLs to:")
set AppleScript's text item delimiters to ","
repeat with this_URL in the URLs
      do shell script "curl -L " & this_URL & " -o " & POSIX path of the destination 
end repeat
set AppleScript's text item delimiters to ""
    
risposta data 10.08.2011 - 04:17
fonte

Leggi altre domande sui tag