Ver Mensaje Individual
  #3 (permalink)  
Antiguo 06/09/2013, 08:44
Avatar de xkz
xkz
 
Fecha de Ingreso: junio-2012
Mensajes: 24
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: Escapar string para preg_match

Discúlpame, me refería a usar delimitadores en la string, ya que estoy intentando hacer curl para obtener el número de suscriptores de un canal en youtube y no la debo estar haciendo bn :S

Dejo aquí el code completo
Código:
<?php

//YOUTUBE INTEL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.youtube.com/user/channelintel");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: es-es,en"));
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


//GUARDAR PAGINA
$result = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);


//PARSEAR
$regex = '<span class="yt-subscription-button-subscriber-count-branded-horizontal subscribed">(.*)</span>'; //AQUÍ ESTÁ SIN DELIMITAR
preg_match($regex, $result, $matches);

$suscriptores = $matches[0];
echo "Suscriptores: " . $suscriptores;




?>