Come specificare la posizione con wget?

Ho bisogno che i file vengano scaricati in /tmp/cron_test/. Il mio codice wget è

wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/

Quindi c'è qualche parametro per specificare la directory?

Soluzione

Dalla pagina del manuale:

-P prefix
--directory-prefix=prefix
           Set directory prefix to prefix.  The directory prefix is the
           directory where all other files and sub-directories will be
           saved to, i.e. the top of the retrieval tree.  The default
           is . (the current directory).

Quindi devi aggiungere -P /tmp/cron_test/ (forma breve) o --directory-prefix=/tmp/cron_test/ (forma lunga) al tuo comando. Nota anche che se la directory non esiste verrà creata.

Commentari (6)

-O è l'opzione per specificare il percorso del file che volete scaricare.

wget  -O /path/to/folder/file.ext

-P è il prefisso dove scaricherà il file nella directory

wget  -P /path/to/folder
Commentari (4)

prova questo metodo -

import os
path = raw_input("enter the url:")
fold = raw_input("enter the folder:")
os.system('wget -r -nd -l1 -P %s --no-parent -A mp3 %s'%(fold, path))
Commentari (2)