Curl www.google.com works differently when a URL is called directly from a browser

Do you have a question regarding curl

When I type curl www.google.comin the terminal, I get below answer. But when I type in a similar URL (www.google.com) in the browser (chrome), I redirect to www.google.co.in

Question: why can't I see below html when I call the same URL from browser

<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>

thanks Amit

+5
source share
2 answers

Browsers automatically follow redirects, so that the intermediate page will be available only for a microscopic fraction of the time before loading the .co.inpage. CURL, by default, does NOT follow redirects, so instead you get an intermediate page.

+2
curl -L http://www.google.com

, .

+9

All Articles