我使用wget下载网站内容,但是wget是一个一个下载文件的。
我怎么能让wget下载使用4个同时连接?
我使用wget下载网站内容,但是wget是一个一个下载文件的。
我怎么能让wget下载使用4个同时连接?
当前回答
考虑使用正则表达式或FTP Globbing。通过这种方法,您可以使用不同的文件名起始字符组多次启动wget,这取决于它们出现的频率。
这是我如何在两个NAS之间同步文件夹的例子:
wget --recursive --level 0 --no-host-directories --cut-dirs=2 --no-verbose --timestamping --backups=0 --bind-address=10.0.0.10 --user=<ftp_user> --password=<ftp_password> "ftp://10.0.0.100/foo/bar/[0-9a-hA-H]*" --directory-prefix=/volume1/foo &
wget --recursive --level 0 --no-host-directories --cut-dirs=2 --no-verbose --timestamping --backups=0 --bind-address=10.0.0.11 --user=<ftp_user> --password=<ftp_password> "ftp://10.0.0.100/foo/bar/[!0-9a-hA-H]*" --directory-prefix=/volume1/foo &
第一个wget同步所有以0,1,2…开头的文件/文件夹。F, G, H和第二个线程同步所有其他内容。
这是在带有一个10G以太网端口(10.0.0.100)的NAS和带有两个1G以太网端口(10.0.0.10和10.0.0.11)的NAS之间进行同步的最简单方法。我通过——bind-address将两个wget线程绑定到不同的以太网端口,并通过在每行末尾放置&将它们称为并行。通过这种方式,我能够复制2x 100mb /s = 200 MB/s的大文件。
其他回答
他们总是说这要视情况而定,但当谈到镜像网站时,最好的是httrack。这是超级快速和容易工作。唯一的缺点是它是所谓的支持论坛,但你可以使用官方文档找到你的方法。它有GUI和CLI界面,它支持cookie,只是阅读文档,这是最好的。(用这个工具你可以在你的硬盘上下载整个网络)
httrack -c8 [url]
默认情况下,最大同时连接数限制为8,以避免服务器过载
尝试pcurl
http://sourceforge.net/projects/pcurl/
使用curl代替wget,并行下载10段。
另一个可以做到这一点的程序是axel。
axel -n <NUMBER_OF_CONNECTIONS> URL
对于基本的HTTP认证,
axel -n <NUMBER_OF_CONNECTIONS> "user:password@https://domain.tld/path/file.ext"
Ubuntu手册页。
您可以使用xargs
-P是进程数,例如设置-P 4,将同时下载4个链接,如果设置-P 0, xargs将启动尽可能多的进程,并下载所有的链接。
cat links.txt | xargs -P 4 -I{} wget {}
我发现(可能) 一个解决方案
In the process of downloading a few thousand log files from one server to the next I suddenly had the need to do some serious multithreaded downloading in BSD, preferably with Wget as that was the simplest way I could think of handling this. A little looking around led me to this little nugget: wget -r -np -N [url] & wget -r -np -N [url] & wget -r -np -N [url] & wget -r -np -N [url] Just repeat the wget -r -np -N [url] for as many threads as you need... Now given this isn’t pretty and there are surely better ways to do this but if you want something quick and dirty it should do the trick...
注意:选项-N使wget只下载“更新的”文件,这意味着它不会覆盖或重新下载文件,除非它们在服务器上的时间戳发生了变化。