与Web服务器的目录列表同步


14

有没有一种简单的方法可以使文件夹通过HTTP与目录列表同步?

编辑

感谢wget的提示!我创建了一个shell脚本并将其添加为cron作业:

remote_dirs=( "http://example.com/" "…") # Add your remote HTTP directories here
local_dirs=(  "~/examplecom" "…")

for (( i = 0 ; i < ${#local_dirs[@]} ; i++ )) do
cd "${local_dirs[$i]}"
wget -r -l1 --no-parent -A "*.pdf" -nd -nc ${remote_dirs[$i]}
done

# Explanation:
# -r            to download recursively
# -l1           to include only one directory depth
# --no-parent   to exclude parent directories
# -A "*.pdf"    to accept only .pdf files
# -nd           to prevent wget to create directories for everything
# -N            to make wget to download only new files

编辑2: 如下所述,也可以使用--mirror-m),它是的简写-r -N


很高兴它有所帮助。您能否接受最能帮助您解决问题的答案?
乔治M

Answers:


16

wget 是一个很棒的工具。

采用 wget -m http://somesite.com/directory

-m
--mirror
    Turn on options suitable for mirroring.  This option turns on
    recursion and time-stamping, sets infinite recursion depth and
    keeps FTP directory listings.  It is currently equivalent to 
    -r -N -l inf --no-remove-listing.

7

类似于rsync,但是使用zsync从httpd服务器获取。


Internet上关于zsync的文档很少。如果您能详细说明您的答案,那将是非常好的。谢谢。
Behrooz

3
Behrooz-我现在实际使用lftp及其mirror命令。
gogators 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.