Good evening friends today I was raised a question I'm using Curl to extract some data from a website in this way.
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$url = 'https://ycapi.org/iframe/?v=6YzGOq42zLk';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER,0); //visualizar ñ y acentos.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CAINFO, 'cacert.pem');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate"); //(aceptación de codificación gzip)
$response = curl_exec($ch); //almacena el response de la pagina.
curl_close($ch);
if (preg_match('#rel="nofollow" href=[^"]*"([^"]*)"#', $response, $datos)) {
$mp = $datos[1];
} else {
$mp = 'error';
}
echo $mp;
The code is good The problem is that the page where I extract the data have to wait a while to process the information and curl does not wait for that time and extracts the null data.
The question is, is there a way to make curl wait for the information to be available to extract the page.
I thought to use
sleed ();
But I really do not know where to locate, thank you in advance.