我使用wget下载网站内容,但是wget是一个一个下载文件的。
我怎么能让wget下载使用4个同时连接?
我使用wget下载网站内容,但是wget是一个一个下载文件的。
我怎么能让wget下载使用4个同时连接?
当前回答
use
aria2c -x 10 -i websites.txt >/dev/null 2>/dev/null &
在sites.txt中每行放一个url,例如:
https://www.example.com/1.mp4
https://www.example.com/2.mp4
https://www.example.com/3.mp4
https://www.example.com/4.mp4
https://www.example.com/5.mp4
其他回答
使用咏叹调2:
aria2c -x 16 [url]
# |
# |
# |
# ----> the number of connections
http://aria2.sourceforge.net
我发现(可能) 一个解决方案
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只下载“更新的”文件,这意味着它不会覆盖或重新下载文件,除非它们在服务器上的时间戳发生了变化。
make可以很容易地并行化(例如,make -j 4)。例如,这是一个简单的Makefile,我正在使用wget并行下载文件:
BASE=http://www.somewhere.com/path/to
FILES=$(shell awk '{printf "%s.ext\n", $$1}' filelist.txt)
LOG=download.log
all: $(FILES)
echo $(FILES)
%.ext:
wget -N -a $(LOG) $(BASE)/$@
.PHONY: all
default: all
使用xargs使wget在多个文件中并行工作
#!/bin/bash
mywget()
{
wget "$1"
}
export -f mywget
# run wget in parallel using 8 thread/connection
xargs -P 8 -n 1 -I {} bash -c "mywget '{}'" < list_urls.txt
Aria2选项,正确的工作方式与文件小于20mb
aria2c -k 2M -x 10 -s 10 [url]
-k 2M将文件分割成2mb的块
-k或——min-split-size的默认值是20mb,如果你不设置这个选项并且文件小于20mb,无论-x或-s的值是多少,它都只会在单个连接中运行
他们总是说这要视情况而定,但当谈到镜像网站时,最好的是httrack。这是超级快速和容易工作。唯一的缺点是它是所谓的支持论坛,但你可以使用官方文档找到你的方法。它有GUI和CLI界面,它支持cookie,只是阅读文档,这是最好的。(用这个工具你可以在你的硬盘上下载整个网络)
httrack -c8 [url]
默认情况下,最大同时连接数限制为8,以避免服务器过载