检索 URL 内容并遵循重定向

检索 URL 内容并遵循重定向

我想访问 CentOS 中的 URL,然后自动遵循重定向。因此,例如:

Visit http://domain.com
This will redirect my by a `header()` to another webpage, so automatically follow this redirect.
And this page will also redirect me.
Save the contents on the `landing` page.

我该如何实现这个目标?

答案1

curl -L http://domain.com

-L/--location
(HTTP/HTTPS) 如果服务器报告请求的页面已移动到不同的位置(用 Location: 标头和 3XX 响应代码指示),此选项将使curl 在新位置重做请求。

或者wget http://domain.com

相关内容