2012-07-16 74 views

回答

55

你可以這樣做:

wget -r -l1 --no-parent http://www.domain.com/subdirectory/

其中:

-r: recursive retrieving 
-l1: sets the maximum recursion depth to be 1 
--no-parent: does not ascend to the parent; only downloads from the specified subdirectory and downwards hierarchy 
+4

感謝您打破命令參數。我有一個類似的問題,但只需要-r和--no-parent命令。 – Sofox 2013-10-12 20:06:08

+1

如果您希望確保每個頁面都可以正確加載(即:下載加載在頁面上的圖像),則可以將** - p **標誌添加到上述命令中。 – earthmeLon 2014-04-14 18:31:09

+0

此外,添加'-nd'將文件直接保存在當前目錄中,而不需要/ path/to/the /子目錄。 – HenriV 2017-04-26 12:03:33

5
$ wget -m -p -E -k -K -np {URL Address} 

您可以使用手冊頁選項的詳細信息。

注意:與以前的選項,索引的文件將被下載!

+0

瘋了。正是我所期待的。這應該是被接受的答案。 – 2015-05-29 12:05:10

+1

這個解決方案在我的情況下失敗(建立在linux-gnu上的GNU Wget 1.13.4)。它實際上是在父目錄中下載文件---而不是所需的結果。 – 2016-04-29 18:53:27

+1

在我的情況下,它也失敗了。看來我的'wget'(GNU Wget 1.14)忽略了'--no-parent選項'。在openSUSE閏日42.1.20160217 – boczniak767 2016-07-08 09:59:27

2

我可以使用的良好信息。我想:

 
wget -r -l1 --no-parent http://www.domain.com/subdirectory/ 

的網站上,其中包括形式name.subname.subname2.etc.htm或.html的多個文件。爲了挑選這些,我跑了:

 
wget -r --no-parent http://www.domain.com/subdirectory/ 

,這工作得很好。