我正在尝试使用 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/