Cómo obtener el marcado html de google.com usando curl
Frecuentes
Visto 92 equipos
1
I'm write the follwoing:
$ch= curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL,
"http://google.com/");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
$output= curl_exec($ch);
curl_close($ch);
if($output==FALSE) return 'No markup';
return $output;
and html markup for receiving markup of google.com
:
<div class="content">
<pre>
<?php
echo htmlentities($output);
?>
</pre>
</div>
But when I'm running this script pre tag is contain nada. Why? If I replaced google.com to stackoverflow.com then it works fine. How to fix this?
0 Respuestas
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas php curl or haz tu propia pregunta.
I guess that Google blocks the user agent of curl. - rekire
I guess that google redirects you from
http
ahttps
. - u_mulderWith your code I get a valid response and a string length of 44,822 - Scuzzy
for debugging curl requests i do 2 things: 1) curl_getinfo for debugging headers 2) curl_setopt($ch, CURLOPT_VERBOSE, true); for extended information about request proccess - Nikita U.