Skip to content
Snippets Groups Projects
monitor_recherche.php 1.17 KiB
<?php
error_reporting(E_ALL^E_DEPRECATED);

if (!isset($argv[1])) {
  echo 'I need bokeh URL !!';
  exit(1);
}


function new_recherche($expression_recherchee, $url){
	$cookie_file = tempnam("/tmp", "cookie");
	$url_recherche = $url . '/recherche/simple/expressionRecherche/';

	$curl_old_step_1 = curl_init($url_recherche.$expression_recherchee);
	curl_setopt($curl_old_step_1,CURLOPT_COOKIEJAR, $cookie_file);
	curl_setopt($curl_old_step_1,CURLOPT_COOKIEFILE, $cookie_file);
	curl_setopt($curl_old_step_1,CURLOPT_RETURNTRANSFER, true);

	$result_old_step_1 = curl_exec($curl_old_step_1);
	$total_time  = curl_getinfo($curl_old_step_1,CURLINFO_TOTAL_TIME );
	curl_close($curl_old_step_1);

	echo date("H:i:s")." : $total_time s  [$expression_recherchee]\n";
	return $total_time;
}


// main
while(true) {
	foreach(['sport',
           'france',
           'pomme',
           'informatique',
           'plaine',
           'poire',
           'histoire',
           'camille',
           'mysql',
           'ukulélé',
           'minion',
           'partition',
           'musique',
           'théatre',
           'cinéma'] as $terme) {
		new_recherche($terme, $argv[1]);
		sleep(5);
	}
}

?>