wget下载文件

墨蓝 2022-03-12 05:42 382阅读 0赞

Wget

  1. The non-interactive network downloader.
  2. 非交互网络下载器。
  3. wget [option]... [URL]...
  4. Wget is non-interactive, meaning that it can work in the background, while the user is not logged on.
  5. wget是非交互性的,这意味着它可以在后台工作,而用户则不登录。
  6. This allows you to start a retrieval and disconnect from the system, letting Wget finish the work.
  7. 这可以让你开始检索和断开与系统,让Wget完成工作。
  8. By contrast, most of the Web browsers require constant user's presence, which can be a great hindrance when transferring a lot of data.
  9. 相比之下,大多数网页浏览器都需要用户的不断出现,这在传输大量数据时可能是一个很大的障碍。
  10. Wget can follow links in HTML, XHTML, and CSS pages, to create local versions of remote web sites, fully recreating the directory structure of the original site.
  11. wget可以遵循html、xhtml和css页面中的链接,创建远程网站的本地版本,完全重新创建原始网站的目录结构。
  12. This is sometimes referred to as "recursive downloading."
  13. 这有时被称为“递归下载”。
  14. While doing that, Wget respects the Robot Exclusion Standard (/robots.txt).
  15. 在这样做的同时,Wget尊重机器人排除标准(/robots.txt)。
  16. Wget can be instructed to convert the links in downloaded files to point at the local files, for offline viewing.
  17. wget可以被指示将下载文件中的链接转换为指向本地文件,以便离线查看。
  18. Wget has been designed for robustness over slow or unstable network connections;
  19. Wget已经被设计为对慢或不稳定的网络连接的鲁棒性;
  20. if a download fails due to a network problem, it will keep retrying until the whole file has been retrieved.
  21. 如果由于网络问题下载失败,它将继续重试,直到检索到整个文件。
  22. If the server supports regetting,it will instruct the server to continue the download from where it left off.
  23. 如果服务器支持重置,它将指示服务器继续从其中断的地方下载。
  24. Wget does not support Client Revocation Lists (CRLs) so the HTTPS certificate you are connecting to might be revoked by the siteowner.
  25. Wget不支持客户端撤销列表(crl),因此您连接到的https证书可能被站点所有者撤销。

下载文件到当前目录

  1. wget http://uploads.oh100.com/allimg/1709/117-1FZ5102542-52.jpg
  2. 在下载的过程中会显示进度条,包含(下载完成百分比,已经下载的字节,当前下载速度,剩余下载时间)。

下载并以不同的文件名保存-O

  1. wget -O wordpress.zip http://www.linuxde.net/download.aspx?id=1080
  2. wget默认会以最后一个符合/的后面的字符来命令,对于动态链接的下载通常文件名会不正确。
  3. 错误:下面的例子会下载一个文件并以名称download.aspx?id=1080保存:
  4. wget http://www.linuxde.net/download?id=1
  5. 即使下载的文件是zip格式,它仍然以download.php?id=1080命令。
  6. 正确:为了解决这个问题,我们可以使用参数-O来指定一个文件名:
  7. wget -O wordpress.zip http://www.linuxde.net/download.aspx?id=1080

wget限速下载–limit-rate=300k

  1. wget --limit-rate=300k http://uploads.oh100.com/allimg/1709/117-1FZ5102542-52.jpg
  2. 当你执行wget的时候,它默认会占用全部可能的宽带下载。但是当你准备下载一个大文件,而你还需要下载其它文件时就有必要限速了。

使用wget断点续传-c

  1. wget -c http://www.linuxde.net/testfile.zip
  2. 使用wget -c 重新启动下载中断的文件,对于我们下载大文件时突然由于网络等原因中断非常有帮助,我们可以继续接着下载而不是重新下载一个文件。需要继续中断的下载时可以使用-c参数。

使用wget后台下载-b

  1. ubuntu@ip-172-31-3-107:~$ wget --limit-rate=300k -O ps.zip -b http://uploads.oh100.com/allimg/1709/117-1FZ5102542-52.jpg
  2. Continuing in background, pid 12684.
  3. Output will be written to wget-log’.
  4. 对于下载非常大的文件的时候,我们可以使用参数-b进行后台下载,你可以使用以下命令来察看下载进度:
  5. tail -f wget-log

测试下载链接

  1. 当你打算进行定时下载,你应该在预定时间测试下载链接是否有效。我们可以增加--spider参数进行检查。
  2. wget --spider URL
  3. wget --spider http://uploads.oh100.com/allimg/1709/117-1FZ5102542-52.jpg

增加重试次数

  1. wget --tries=40 URL
  2. 如果网络有问题或下载一个大文件也有可能失败。wget默认重试20次连接下载文件。如果需要,你可以使用--tries增加重试次数。

下载多个文件

  1. wget -i filelist.txt
  2. 首先,保存一份下载链接文件:
  3. cat > filelist.txt
  4. url1
  5. url2
  6. url3
  7. url4
  8. 接着使用这个文件和参数-i下载。

把下载信息存入日志文件

  1. wget -o download.log URL

发表评论

表情:
评论列表 (有 0 条评论,382人围观)

还没有评论,来说两句吧...

相关阅读