wget 使用技巧

wget 是一个命令行的下载工具。对于我们这些 Linux 用户来说,几乎每天都在使用它。下面为大家介绍几个有用的 wget 小技巧,可以让你更加高效而灵活的使用 wget。

  • $ wget -r -np -nd http://example.com/packages/

这条命令可以下载 http://example.com 网站上 packages 目录中的所有文件。其中,-np 的作用是不遍历父目录,-nd 表示不在本机重新创建目录结构。

  • $ wget -r -np -nd --accept=iso http://example.com/centos-5/i386/

与上一条命令相似,但多加了一个 --accept=iso 选项,这指示 wget 仅下载 i386 目录中所有扩展名为 iso 的文件。你也可以指定多个扩展名,只需用逗号分隔即可。

  • $ wget -i filename.txt

此命令常用于批量下载的情形,把所有需要下载文件的地址放到 filename.txt 中,然后 wget 就会自动为你下载所有文件了。

  • $ wget -c http://example.com/really-big-file.iso

这里所指定的 -c 选项的作用为断点续传。

  • $ wget -m -k (-H) http://www.example.com/

该命令可用来镜像一个网站,wget 将对链接进行转换。如果网站中的图像是放在另外的站点,那么可以使用 -H 选项。

[via]

Read More:

45 Comments

  1. 1 wyg1258 Commented @ 2007-10-14 10:15Reply to this comment

    很实用的介绍

  2. 2 Anderson Commented @ 2007-10-14 10:15Reply to this comment

    网络状况不好的时候用wget就对了,非常非常稳定

  3. 3 stlxv Commented @ 2007-10-14 11:04Reply to this comment

    “对于我们这些 Linux 用户来说,几乎每天都在使用它。”

    像我这种,是几乎从来不用它.......

  4. 4 biowee Commented @ 2007-10-14 11:09Reply to this comment

    不错!如果使用图形界面的,有gwget可以使用。

  5. 5 Jake Commented @ 2007-10-14 11:31Reply to this comment

    非常有用。谢谢。

  6. 6 lh Commented @ 2007-10-14 15:28Reply to this comment

    如果ie下载有wget这样的功能就好了。再win下下载是越下越慢。linux下没有这样的情况

  7. 7 mumonitor Commented @ 2007-10-14 15:43Reply to this comment

    3,4一直用,其他的学习了,多谢!

  8. 8 zissan Commented @ 2007-10-14 16:16Reply to this comment

    看来我和stlxv属于另类了 :-)

  9. 9 Sutra Commented @ 2007-10-14 16:40Reply to this comment

    To lh: Win 下也有wget for windows 的呀。

  10. 10 ding Commented @ 2007-10-14 17:00Reply to this comment

    学习 收藏了!

  11. 11 wget 使用技巧 at 创意纪 Pingbacked @ 2007-10-14 20:10Reply to this comment

    [...] $ wget -m -k (-H) http://www.example.com/该命令可用来镜像一个网站,wget 将对链接进行转换。如果网站中的图像是放在另外的站点,那么可以使用 -H 选项。 转载自这里。 Related Posts开源搜索引擎Nutch全攻略 [...]

  12. 12 John Commented @ 2007-10-15 9:22Reply to this comment

    wget 也有windows下的版本。我一直在用,非常好用。

  13. 13 sbilly Commented @ 2007-10-15 10:16Reply to this comment

    我也一直用 wget 呵呵~ Linux/Solaris/Windows ...

  14. 14 My Open Course Ware » wget 使用技巧 Pingbacked @ 2007-10-15 11:09Reply to this comment

    [...] Linux下很有用的下载工具wget的使用方法。虽然直接man可以得到,但是人家整理出来并翻译了,吸收消化还是很不错的。转载自LinuxTOY,原文在这里: [...]

  15. 15 NightOwl Commented @ 2007-10-15 14:46Reply to this comment

    对于上面的朋友说的在windows下不能用wget的问题,有一个比较好的解决方案。Ming Bai(http://mbbill.googlepages.com/)推荐了一个 unxutils 的windows工具包。里面包括了静态编译好的很多unix/Linux下面的工具(当然包括wget)。这个包的好处是体积非常小,而且不依赖任何动态连接库。感兴趣的朋友可以在如下地址下载到:http://unxutils.sourceforge.net/

  16. 16 sendney Commented @ 2007-10-15 22:31Reply to this comment

    wget支持多线程下载吗???

  17. 17 宏奋 Commented @ 2007-10-17 1:04Reply to this comment

    to sendney:

    wget不支持多线程下载, 要想用多线程方式,推荐用axel,请google:)

  18. 18 islet8 Commented @ 2007-10-17 9:25Reply to this comment

    @sendney:据说多线程下载是中国特色,本身对服务器来说弊大于利 wget的单线程模式仍然很快啊,不信你试试,我现在主要都用gwget,像d4x、multiget都不用了

  19. 19 links for 2007-10-17 « /tmp Pingbacked @ 2007-10-18 0:18Reply to this comment

    [...] wget 使用技巧 - LinuxTOY (tags: linux wget) [...]

  20. 20 linuxl Commented @ 2007-10-18 16:38Reply to this comment

    linux的镜像一般都挺快,单线程足够了~

  21. 21 links for 2007-10-19 at Systems Thoughts Pingbacked @ 2007-10-20 7:21Reply to this comment

    [...] wget 使用技巧 - LinuxTOY (tags: linux tip wget) Leave a Reply [...]

  22. 22 use wget at Spritewood Pingbacked @ 2007-10-30 15:25Reply to this comment

    [...] http://linuxtoy.org/archives/wget-tips.html [...]

  23. 23 wget 使用技巧 | 人生得意须尽欢 Pingbacked @ 2007-11-29 17:24Reply to this comment

    [...] → 转载时务必以超链接形式标明文章原始出处及作者信息。 → 本文网址:http://linuxtoy.org/archives/wget-tips.html [...]

  24. 24 Vayn技术网摘 » wget 使用技巧 Pingbacked @ 2008-02-09 4:04Reply to this comment

    [...] [本文转载自LinuxToy:http://linuxtoy.org/archives/wget-tips.htmlvia [...]

  25. 25 peter’s blog » Blog Archive » 服务器 Pingbacked @ 2008-02-24 16:37Reply to this comment

    [...] 源文档 <http://linuxtoy.org/archives/wget-tips.html&gt; [...]

  26. 26 SpriteWood » Blog Archive » use wget Pingbacked @ 2008-06-23 13:25Reply to this comment

    [...] http://linuxtoy.org/archives/wget-tips.html Tags: wget This entry was posted on Tuesday, October 30th, 2007 at 3:22 pm and is filed under linux. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site. [...]

  27. 27 use wget - SpriteWood Pingbacked @ 2008-08-27 12:22Reply to this comment

    [...] http://linuxtoy.org/archives/wget-tips.html Tagged: linux and wget Feed for this Entry [...]

  28. 28 wget 使用技巧大全 | 嘉佑年轻时代 Pingbacked @ 2008-09-15 0:38Reply to this comment

    [...] Linux发行版 都自带 wget ,那么有多少人像我一样都不会使用呢?除了 linuxtoy.org 上面介绍的小技巧之外,我在网上找了一些 wget [...]

  29. 29 wget 使用技巧大全 - Moxida网摘 Pingbacked @ 2008-09-29 6:54Reply to this comment

    [...] Linux发行版 都自带 wget ,那么有多少人像我一样都不会使用呢?除了 linuxtoy.org 上面介绍的小技巧之外,我在网上找了一些 wget [...]

  30. 30 bill Commented @ 2009-03-26 8:56Reply to this comment

    补充点: 国内有很多下载地址是加了跳转的 ,不能直接wget的,可以在网址上加单引号''这样就可以了

  31. 31 ricky Commented @ 2009-07-16 10:55Reply to this comment

    if the site need login, how to deal with?

    thanks,

  32. 32 Jim Commented @ 2009-09-03 14:37Reply to this comment

    我用kget,感觉也不错

  33. 33 fcicq Commented @ 2010-02-19 16:45Reply to this comment

    多线程抓站肯定用 pavuk.

  34. 34 笔记本电池 Commented @ 2010-02-24 22:30Reply to this comment

    谢谢,wget -q这个又是什么意思?

  35. 35 L_kernel Commented @ 2010-08-01 0:48Reply to this comment

    如何配置使用代理?

  36. 36 tuantuan Commented @ 2010-10-27 23:47Reply to this comment

    -e 'http_proxy=ip:port'

  37. 37 autolzg Commented @ 2010-12-18 18:16Reply to this comment

    我在windows下用wget批量下载美女图片,, ~(@^_^@)~

  38. 38 linuxboy Commented @ 2011-01-18 23:33Reply to this comment

    呵呵,感谢博主的分享。 wget是linux系统的常用软件,下载更多linux软件,可以到 http://dl.v168.tk看一下啊,里边有不少好软件

  39. 39 leopard Commented @ 2011-03-25 8:31Reply to this comment

    Thanks,I have seen it on huihoo.com.But it`s introduction is too simple

  40. 40 snoring remedies Commented @ 2011-06-30 19:18Reply to this comment

    I like this info given and it has given me some sort of inspiration to have success for some reason, so thank you.

  41. 41 Caverta Commented @ 2011-07-07 15:34Reply to this comment

    那么有多少人像我一样都不会使用呢?除了 linuxwget这样的功能就好了。再w

  42. 42 srepc Commented @ 2011-07-11 15:31Reply to this comment

    wget国内的还是很慢

  43. 43 suwt Commented @ 2011-09-30 12:15Reply to this comment

    很变态。我装了个windows版本,结果发现不支持 -np,后果非常严重。我原本想下载一个站点里的music/cd1里的所有mp3,结果最后发现,它把这个站点所有文件都下载了。 虽然,偶尔我也会有这种想法,但没想到它比我想的还要快、方便。。。。 以后啥下载工具都不用装了,一个命令全搞定。。。。 我又淫荡地在笑。。。

  44. 44 Buy Azelex Commented @ 2011-10-17 21:54Reply to this comment

    你的工作非常好,我很欣赏你,并为一些更丰富的职位跳槽。感谢您给我们伟大的信息共享。

  45. 45 yesureadmin Commented @ 2011-11-01 20:03Reply to this comment

    非常棒,我经常来-t200 -d -c 参数