我有一个web目录,我存储一些配置文件。我想使用wget将这些文件拉下来并保持它们当前的结构。例如,远程目录看起来像:
http://mysite.com/configs/.vim/
.vim包含多个文件和目录。我想用wget在客户端复制它。似乎无法找到正确的wget标志组合来完成这项工作。什么好主意吗?
我有一个web目录,我存储一些配置文件。我想使用wget将这些文件拉下来并保持它们当前的结构。例如,远程目录看起来像:
http://mysite.com/configs/.vim/
.vim包含多个文件和目录。我想用wget在客户端复制它。似乎无法找到正确的wget标志组合来完成这项工作。什么好主意吗?
当前回答
使用下面的命令,递归获取用户名和密码的目录:
wget -r --user=(put username here) --password='(put password here)' --no-parent http://example.com/
其他回答
下面的选项似乎是处理递归下载时的完美组合:
wget -nd -n -P -P /dest/dir -充值http://url/dir1 dir2
为方便起见,手册页中的相关片段:
-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).
-np
--no-parent
Do not ever ascend to the parent directory when retrieving recursively. This is a useful option, since it guarantees that only the files below a certain hierarchy will be downloaded.
下面是完整的wget命令,用于从服务器目录下载文件(忽略robots.txt):
wget -e robots=off --cut-dirs=3 --user-agent=Mozilla/5.0 --reject="index.html*" --no-parent --recursive --relative --level=1 --no-directories http://www.example.com/archive/example/5.3.0/
wget -r http://mysite.com/configs/.vim/
对我有用。
也许你有一个。wgetrc干扰它?
您应该使用-m (mirror)标志,因为这样可以避免混淆时间戳并无限地递归。
wget -m http://example.com/configs/.vim/
如果你加上其他人在这篇文章中提到的要点,它将是:
wget -m -e robots=off --no-parent http://example.com/configs/.vim/
你只要加一个-r就可以了
wget -r http://stackoverflow.com/