使用wget递归地获取一个包含任意文件的目录(Using wget to recursively fetch a directory with arbitrary files in it)

编程入门 行业动态 更新时间:2024-10-27 21:24:39
使用wget递归地获取一个包含任意文件的目录(Using wget to recursively fetch a directory with arbitrary files in it)

我有一个web目录,我存储一些配置文件。 我想使用wget将这些文件拉下来并保持当前的结构。 例如,远程目录如下所示:

http://mysite.com/configs/.vim/

.vim拥有多个文件和目录。 我想使用wget在客户端上复制。 似乎找不到wget标志的正确组合来完成这一切。 有任何想法吗?

I have a web directory where I store some config files. I'd like to use wget to pull those files down and maintain their current structure. For instance, the remote directory looks like:

http://mysite.com/configs/.vim/

.vim holds multiple files and directories. I want to replicate that on the client using wget. Can't seem to find the right combo of wget flags to get this done. Any ideas?

最满意答案

对我来说,我必须传递--no-parent选项,否则它会按照我的站点上的目录索引中的链接到父目录。 所以命令将如下所示:

wget -r --no-parent http://example.com/configs/.vim/

编辑1:为避免下载index.html文件,请使用以下命令:

wget -r --no-parent --reject "index.html*" http://example.com/configs/.vim/

编辑2:为了避免下载目录结构:

wget -r -nH -nd -np -R index.html* http://example.com/configs/.vim/

You have to pass the -np/--no-parent option to wget (in addition to -r/--recursive, of course), otherwise it will follow the link in the directory index on my site to the parent directory. So the command would look like this:

wget --recursive --no-parent http://example.com/configs/.vim/

To avoid downloading the auto-generated index.html files, use the -R/--reject option:

wget -r -np -R "index.html*" http://example.com/configs/.vim/

更多推荐

本文发布于:2023-08-03 20:00:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1395751.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:递归   文件   目录   wget   recursively

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!