使用url重定向下载文件

时间:2013-12-07 11:19:04

标签: bash url curl download wget

我可以通过网址下载文件但是当我从bash尝试时,我会得到一个html页面而不是文件。

如何使用curl,wget或其他方式下载带有网址重定向(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

1 个答案:

答案 0 :(得分:9)

使用-L, --location关注重定向:

$ curl -L http://httpbin.org/redirect/1