当从浏览器直接调用url时,curl www.google.com的工作方式不同

Ami*_*mit 6 curl

有关于卷曲的问题

当我输入curl www.google.com终端时,我得到以下回复.但是当我在浏览器(chrome)中键入类似的URL(www.google.com)时,我会被重定向到www.google.co.in

问题是当我从浏览器调用相同的URL时,我无法看到下面的html

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.co.in/">here</A>.
</BODY></HTML>
Run Code Online (Sandbox Code Playgroud)

谢谢你

Ser*_*min 15

curl -L http://www.google.com
Run Code Online (Sandbox Code Playgroud)

将卷曲跟随重定向,您将收到实际的搜索页面.


Mar*_*c B 6

.co.in浏览器自动遵循重定向,因此中间页面仅在加载页面版本之前的一小部分时间内可用。默认情况下,CURL 不遵循重定向,因此您会得到中间页面。