如何从所有孙子目录中获取文件

How to wget files from all grandchild directories

我有一个网站:http://www.example.com/

此网站有一个子目录:http://www.example.com/images/

该子目录包含许多子目录,其中包含图像:

当我从 images 目录尝试 wget 时,它会下载每个目录(01/02/ 等)和 index.html每一个。它不会下载任何图像。例如

wget -r http://www.example.com/images/ <- 不下载 png

wget -r http://www.example.com/images/01/ <- 是否下载 png

如何使用wgetimages/目录的所有子目录中下载所有png而不需要遍历每个子目录(01/,02/,03/等)一一?

您只需要查看 man wget 即可根据您的要求查找选项。通过快速查找,我找到了这些,

-A acclist --accept acclist         
       Specify comma-separated lists of file name suffixes or patterns to
       accept or reject.

--no-directories
       Do not create a hierarchy of directories when retrieving recursively.
       With this option turned on, all files will get saved to the current directory, 
       without clobbering (if a name shows up more than once, the filenames will get extensions .n).

Recursive Retrieval Options
-r
--recursive
       Turn on recursive retrieving. The default maximum depth is 5.

将这些组合在一起,您可以将命令组合在一起

wget -nd -r -A png http://www.example.com/images/