使用网址重定向下载文件 [英] Download file with url redirection

查看:160
本文介绍了使用网址重定向下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I can download a file by url but when I try it from bash I get a html page instead of a file.

如何使用url重定向下载文件( 301永久移动)是否使用卷曲,wget或其他东西?

How to download file with url redirection (301 Moved Permanently) using curl, wget or something else?

UPD

url请求的标头。


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


推荐答案

使用 -L,--location 跟随重定向:

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

这篇关于使用网址重定向下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆