我需要將文件下載到/ tmp/cron_test /。我的wget代碼是如何用wget指定位置?
wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/
那麼是否有一些參數來指定目錄?
我需要將文件下載到/ tmp/cron_test /。我的wget代碼是如何用wget指定位置?
wget --random-wait -r -p -nd -e robots=off -A".pdf" -U mozilla http://math.stanford.edu/undergrad/
那麼是否有一些參數來指定目錄?
從手冊頁:
-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).
所以你需要添加-P /tmp/cron_test/
到您的命令。
試試這個方法 -
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))
-O是指定要下載的文件的路徑選擇。
wget <file.ext> -O /path/to/folder/file.ext
-P是前綴,它會下載文件中的目錄
wget <file.ext> -P /path/to/folder
請確保您有正確的網址爲無論你是首先的下載,網址中的人物,如'?'
和這樣的無法解析和解析,這會混淆cmd行並接受任何未解析爲源url名稱的字符作爲要下載到的文件名。
即,wget "sourceforge.net/projects/ebosse/files/latest/download?source=typ_redirect"
將下載到名爲?source=typ_redirect
的文件中。
正如你所看到的,瞭解一些關於urls的東西有助於理解wget。
我從hirens磁盤啓動,只有Linux 2.6.1作爲資源(導入操作系統不可用)。這解決了我的問題,下載一個iso到物理硬盤驅動器的正確語法,就是:
wget "(source url)" -O (directory where HD was mounted)/isofile.iso"
一個可以通過wget的下載發現在什麼點到一個名爲「index.html的」文件圖正確的網址。(默認文件),並有你需要通過以下命令顯示文件的正確大小/其他屬性:
wget "(source url)"
一旦URL和源文件是正確的,它被下載到的index.html,你可以停止下載(ctrl + z)並通過在源URL之後使用 -O "<specified download directory>/filename.extension"
來更改輸出文件。
在我的情況下,這導致下載一個iso並將其作爲二進制文件存儲在isofile.iso下,希望能夠掛載它。
人的wget: -O文件 --output文檔=文件
wget "url" -O /tmp/cron_test/<file>
在Unix的SE類似:使用wget下載到不同的目錄比當前目錄](HTTP://unix.stackexchange的.com/q /21471分之23501)。 – kenorb 2015-08-11 23:47:57