使用wget进行部分下载

10 command-line curl wget

我看到curl支持部分下载

-r, --range RANGE   Retrieve only the bytes within a range
Run Code Online (Sandbox Code Playgroud)

curl -r 0-99 http://foo.com/bar.mp4
Run Code Online (Sandbox Code Playgroud)

但是,可以wget完成类似的事情吗?

Sab*_*san 9

不幸的wget是没有这个功能(至少和我一样GNU Wget 1.10.2 (Red Hat modified)),这很烦人.您可以使用HTTP请求发送Range标头,但不起作用.

wget "http://www.example.com"  -c --header="Range: bytes=0-99"
Run Code Online (Sandbox Code Playgroud)

它回来了

HTTP request sent, awaiting response... 206 Partial Content
Giving up.
Run Code Online (Sandbox Code Playgroud)

似乎wget有适当的反应,但奇怪的是,它没有完成它.例如,使用详细模式输出:

HTTP request sent, awaiting response... 
  HTTP/1.0 206 Partial Content
  Accept-Ranges: bytes
  Cache-Control: max-age=604800
  Content-Range: bytes 0-99/1270
  Content-Type: text/html
  Date: Fri, 24 Jan 2014 08:35:18 GMT
  Etag: "359670651"
  Expires: Fri, 31 Jan 2014 08:35:18 GMT
  Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
  Server: ECS (ftw/FBA9)
  X-Cache: HIT
  Content-Length: 100
  Connection: keep-alive
Giving up.
Run Code Online (Sandbox Code Playgroud)

  • 请参阅 [wget 问题 #20416](http://savannah.gnu.org/bugs/?func=detailitem&item_id=20416) (2认同)