Kaip nurodyti vietą naudojant wget?

Man reikia, kad failai būtų atsisiunčiami į /tmp/cron_test/. Mano wget kodas yra

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

Taigi, ar yra koks nors parametras, nurodantis katalogą?

Sprendimas

Iš vadovo puslapio:

-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).

Taigi į komandą reikia įrašyti -P /tmp/cron_test/ (trumpoji forma) arba --directory-prefix=/tmp/cron_test/ (ilgoji forma). Taip pat atkreipkite dėmesį, kad jei katalogas neegzistuoja, jis bus sukurtas.

Komentarai (6)

-O - tai parinktis, kuria galima nurodyti failo, į kurį norite atsisiųsti, kelią.

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

-P yra priešdėlis, į kurį bus atsisiųstas failas kataloge

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

išbandykite šį metodą -

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))
Komentarai (2)