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

标签 linux bash http redirect 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 重定向超出

尝试这个命令

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

--max-redirect=number

Specifies the maximum number of redirections to follow for a resource. The default is 20, which is usually far more than necessary. However, on those occasions where you want to allow more (or fewer), this is the option to use.

--content-disposition If this is set to on, experimental (not fully-functional) support for Content-Disposition headers is enabled. This can currently result in extra round-trips to the server for a HEAD request, and is known to suffer from a few bugs, which is why it is not currently enabled by default.

关于linux - 从使用 wget 重定向的页面获取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55645615/

相关文章:

Linux Bash 脚本 grep 错误

linux - TrustZone 内存分区

python - 绑定(bind)套接字时权限被拒绝

bash - PS1 换行有颜色问题

java - 异步 HTTP 客户端加载了太多数据?

linux - 内核升级到 3.15.1 后报错

bash - 进程替换不适用于 sudo

linux - 如何在终端中以静默模式运行 Mocha 测试

java - J2me多线程http数据从另一个线程泄漏

node.js - 如何使用 React Router 从 React.js 的子路径修复错误的代理重定向?