使用url重定向下载文件

ede*_*dem 16 url bash curl wget download

我可以通过url下载文件但是当我从bash尝试它时,我得到一个html页面而不是文件.

如何使用curl,wget或其他方式下载带有url重定向的文件(301 Moved Permanently)?

UPD

来自网址请求的标头.

curl -I http://www.somesite.com/data/file/file.rar

HTTP/1.1 301 Moved Permanently
Date: Sat, 07 Dec 2013 10:15:28 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3
Location: http://www.somesite.com/files/html/archive.html
Vary: Accept-Encoding
Content-Type: text/html
X-Pad: avoid browser bug
Run Code Online (Sandbox Code Playgroud)

del*_*eil 20

使用-L, --location遵循重定向:

$ curl -L http://httpbin.org/redirect/1
Run Code Online (Sandbox Code Playgroud)

  • 对我有用。例如,我正在下载重定向的 jenkins war 文件,我可以执行 `curl -O -L http://mirrors.jenkins.io/war-stable/2.60.1/jenkins.war` (2认同)