bash 使用 url 重定向下载文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20440706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Download file with url redirection
提问by edem. С Днём Победы
I can download a file by url but when I try it from bash I get a html page instead of a file.
我可以通过 url 下载文件,但是当我从 bash 尝试它时,我得到一个 html 页面而不是一个文件。
How to download file with url redirection (301 Moved Permanently) using curl, wget or something else?
如何使用 curl、wget 或其他方式下载带有 url 重定向(301 永久移动)的文件?
UPD
UPD
Headers from the url request.
来自 url 请求的标头。
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
回答by deltheil
Use -L, --location
to follow redirects:
使用-L, --location
遵循重定向:
$ curl -L http://httpbin.org/redirect/1