Ver Mensaje Individual
  #4 (permalink)  
Antiguo 29/11/2013, 15:32
Avatar de luis_h_1
luis_h_1
 
Fecha de Ingreso: octubre-2010
Ubicación: México
Mensajes: 42
Antigüedad: 13 años, 6 meses
Puntos: 4
Respuesta: Problema con curl + preg_match_all

Lo acabo de probar en mi pc y si funciona mira:

Código PHP:
Ver original
  1. <?php
  2.  
  3. $url="http://www.loteriasyapuestas.es/es/euromillones/sorteos/2013/855002095";
  4. for($i=1;$i<4; $i++)
  5. {
  6. $handler = curl_init($url);
  7. curl_setopt($handler, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1");
  8. curl_setopt($handler, CURLOPT_HTTPHEADER, array("Accept-Language: es-es,en"));
  9. curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
  10. $pagina = curl_exec ($handler);
  11. curl_close($handler);
  12. $patron="/es/euromillones/sorteos/(.*?)\" title=\"ver anterior\"";
  13. preg_match_all("($patron)iU", $pagina, $anterior);
  14. $anteriora=$anterior[1][0];
  15. $url="http://www.loteriasyapuestas.es/es/euromillones/sorteos/".$anteriora;
  16. echo $url."<br>";
  17. }
  18. ?>