繁体   English   中英

从使用 wget 重定向的页面获取文件

[英]Get files from a page that is redirected using wget

我正在尝试使用wget下载http://someurl.com/123的内容。 问题是http://someurl.com/123被重定向到http://someurl.com/456

我已经尝试使用--max-redirect 0 ,这是我的结果:

wget --max-redirect 0 http://someurl/123
...
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://someurl.com/456 [following]
0 redirections exceeded.

有没有办法获取http://someurl.com/123的实际内容?

默认情况下, wget最多可以跟踪 20 个重定向。 但是由于您将--max-redirect设置为0 ,它返回0 redirections exceeded

试试这个命令

wget --content-disposition http://someurl.com/123

--max-redirect=数字

指定资源要遵循的最大重定向数。 默认值为 20,这通常远远超出必要的范围。 但是,在您希望允许更多(或更少)的情况下,这是可以使用的选项。

--content-disposition如果设置为 on,则启用对 Content-Disposition 标头的实验性(非全功能)支持。 这目前可能会导致 HEAD 请求到服务器的额外往返,并且已知会遇到一些错误,这就是当前默认情况下未启用它的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM