一个页面包含一组.zip文件的链接,我希望将它们全部下载。我知道可以使用wget和curl来完成,具体该如何操作呢?
该命令是:
wget -r -np -l 1 -A zip http://example.com/download/
选项的含义:
-r, --recursive specify recursive download.
-np, --no-parent don't ascend to the parent directory.
-l, --level=NUMBER maximum recursion depth (inf or 0 for infinite).
-A, --accept=LIST comma-separated list of accepted extensions.
wget -r -l1 -H -t1 -nd -N -np -A.mp3 -erobots=off [url of website]
选项的含义:
-r recursive
-l1 maximum recursion depth (1=use only this directory)
-H span hosts (visit other hosts in the recursion)
-t1 Number of retries
-nd Don't make new directories, put downloaded files in this one
-N turn on timestamping
-A.mp3 download only mp3s
-erobots=off execute "robots.off" as if it were a part of .wgetrc
-H
开关的。这就是导致第一个答案(也是我在 SO 上查找之前尝试的)无法正常工作的原因。 - Alex对于其他需要一些并行魔法的场景,我使用:
curl [url] | grep -i [filending] | sed -n 's/.*href="\([^"]*\).*/\1/p' | parallel -N5 wget -
-nd
(无目录)标志很方便。 - Steve Davis