Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/01/2015, 14:39
famjaes
 
Fecha de Ingreso: agosto-2010
Mensajes: 125
Antigüedad: 13 años, 8 meses
Puntos: 0
Sonrisa CURL Multiple

Hola amigos del foro, estoy haciendo un pequeño proyecto que consulta información de varias paginas web cuyo URL almaceno en una base de datos. Sin embargo la consulta de la web se demora hasta 20 segundos así que me puse a investigar si había alguna forma de acelerar la velocidad de curl y esto es mediante culr_multi, sin embargo no se como adaptarlo al código que estoy usando. Si alguien pudiese ayudarme con lo que pueda se lo agradeceré mucho...

Código PHP:
        function file_get_contents_curl($url) {
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    
    $data = curl_exec($ch);
    curl_close($ch);
    
    return $data;
}
 
            include ('./conexion/conexion.php'); 
            $buscar = mysqli_query($cn,"SELECT * FROM mitabla") or die("Error: ".mysqli_error($cn));
            while($al = mysqli_fetch_assoc($buscar)) {
                
        
                
            ?>
  <tr>
    <td><?php
$options 
= array('http' => array(
'method' => 'GET',
));
$configstream_context_create($options);
$config_final=file_get_contents_curl($al['url'],false$config);
preg_match_all("|<div class=\"hora\">(.*)</div>|sU"$config_final$tiempo);
echo 
$tiempo[1][0];
            
?></td>
  </tr>
  <tr>
  <?php }?>