我可以使用 wget -x 下载文件夹结构但不创建域目录吗?

我可以使用 wget -x 下载文件夹结构但不创建域目录吗?

我目前正在这样做:

wget -i download.txt -x

它创建一个根目录example.org/。我想做的只是创建子目录。

有没有办法强迫 wget 做我想做的事?

答案1

根据手册页,该参数-nH应该满足您的要求:

   Directory Options
   -nd
   --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).

   -x
   --force-directories
       The opposite of -nd---create a hierarchy of directories, even if one would not have been created
       otherwise.  E.g. wget -x http://fly.srk.fer.hr/robots.txt will save the downloaded file to
       fly.srk.fer.hr/robots.txt.

   -nH
   --no-host-directories
       Disable generation of host-prefixed directories.  By default, invoking Wget with -r
       http://fly.srk.fer.hr/ will create a structure of directories beginning with fly.srk.fer.hr/.  This
       option disables such behavior.

我不确定您是否真的需要-i示例中使用的参数。

从我的角度来看,要实现您所描述的目标就足以运行:

wget -xnH download.txt

相关内容