I'm trying to get an html markup of google.com using curl in php. I write the following:
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output= curl_exec($ch);
curl_close($ch);
return $output;
The following markup is displayed:
<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.ru/?gfe_rd=cr&ei=xwX7UuzqNuuk4ATU0YHACQ">here</A>.
</BODY>
</HTML>
Now I'm changed php code to the following:
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.ru/?gfe_rd=cr&ei=xwX7UuzqNuuk4ATU0YHACQ");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$output= curl_exec($ch);
curl_close($ch);
return $output;
But it doesn't work. $output
doesn't contains markup of google.com
. How to fix this?