【问题标题】:Multiple downloads with wget at the same time同时使用 wget 进行多个下载
【发布时间】:2018-07-16 08:25:21
【问题描述】:

我有一个包含多个下载链接的link.txt,所有链接都受相同的用户名和密码保护。

我的意图是同时下载多个文件,如果文件包含5个链接,则同时下载所有5个文件。

我试过了,但没有成功。

cat links.txt | xargs -n 1 -P 5 wget --user user007 --password pass147
and
cat links.txt | xargs -n 1 -P 5 wget --user=user007 --password=pass147

给我这个错误:

重用现有连接到 www.site.com 发送的 HTTP 请求, 等待响应... 404 Not Found

此消息出现在我尝试下载的所有链接中,除了文件中开始下载的最后一个链接。

我目前正在使用,但这次只下载一个文件

wget -user=admin --password=145788s -i links.txt

【问题讨论】:

  • (1) cat links.txt | xargs 最好写成< links.txt xargs。 (2) 如果密码包含对 shell 来说特殊的字符,您可能需要引用密码,例如 *。 (3) 先尝试运行< links.txt xargs -n 1 -P 5 /bin/echo wget --user=user007 --password="pass147*",看看xargs到底在运行什么命令。
  • 是的,我目前使用的是:wget --user user007 --password "pass147*" -b -i links.txt,密码暂时不包含任何特殊字符。但是上面的命令一次只下载一个文件输入你给我的命令给我扔了一大堆wget --user=454545 --password=4546,但是不要运行或下载任何文件。
  • 我建议的命令的重点是让你看看xargs会执行什么。如果您对要执行的命令感到满意,则删除/bin/echo。并查看@VDR 的答案——它避免了对xargs 的需要。

标签: linux ubuntu download wget xargs


【解决方案1】:

使用 wget 的 -i-b 标志。

-b
       --background
           Go to background immediately after startup.  If no output file is specified via the -o, output is redirected to wget-log.


-i file
       --input-file=file
           Read URLs from a local or external file.  If - is specified as file, URLs are read from the standard input.  (Use ./- to read from a file literally named -.)

您的命令将如下所示: wget --user user007 --password "pass147*" -b -i links.txt

注意:您应该始终用特殊字符(例如:*)引用字符串。

【讨论】:

    猜你喜欢
    • 2011-03-26
    • 1970-01-01
    • 1970-01-01
    • 2014-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-27
    相关资源
    最近更新 更多