<?php error_reporting(E_ALL^E_DEPRECATED); function old_recherche($expression_recherchee){ $cookie_file = tempnam("/tmp", "cookie"); $url_recherche = "http://web.afi-sa.net/pergame-enligne.net/recherche/simple"; // OLD recherche Step1 fill cookie $curl_old_step_1 = curl_init($url_recherche); 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); curl_setopt($curl_old_step_1,CURLOPT_POSTFIELDS, 'expressionRecherche='.$expression_recherchee); curl_setopt($curl_old_step_1,CURLOPT_POST, true); $result_old_step_1 = curl_exec($curl_old_step_1); $temps_step_1 = curl_getinfo($curl_old_step_1,CURLINFO_TOTAL_TIME ); curl_close($curl_old_step_1); // OLD recherche Step2 recherche/simple avec cookie $curl_old_step_2 = curl_init($url_recherche); curl_setopt($curl_old_step_2,CURLOPT_COOKIEJAR, $cookie_file); curl_setopt($curl_old_step_2,CURLOPT_COOKIEFILE, $cookie_file); curl_setopt($curl_old_step_2, CURLOPT_RETURNTRANSFER, true); $result_old_step_2 = curl_exec($curl_old_step_2); $temps_step_2 = curl_getinfo($curl_old_step_2,CURLINFO_TOTAL_TIME ); curl_close($curl_old_step_2); if (false == strpos($result_old_step_2, 'Recherche : '.$expression_recherchee)) { echo "Error\n"; } echo "- requete: $temps_step_1\n"; echo "- resultat: $temps_step_2\n"; $total_time = $temps_step_1 + $temps_step_2; echo "- total: $total_time\n"; return $total_time; } function new_recherche($expression_recherchee){ $cookie_file = tempnam("/tmp", "cookie"); $url_recherche = "http://opacce.pergame.net/opacce.pergame.net/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); if (false == strpos($result_old_step_1, 'Recherche: '.$expression_recherchee)) { echo "Error\n"; } echo "+ total: $total_time\n"; return $total_time; } // main $recherches = [ 'auteur', 'Millenium', 'France', 'Livre', 'loisirs', 'sports', 'jardin', 'informatique', 'univers', 'bouteille', 'eau', 'telephone', 'Mac', 'Hercule', 'Emacs', 'Ordinateur', 'son', 'Millenium']; $total_old = 0; $total_new = 0; foreach($recherches as $i => $expression) { echo "$i.$expression\n"; $total_old = $total_old + old_recherche($expression); $total_new = $total_new + new_recherche($expression); } echo "== TOTAL OLD: $total_old\n"; echo "== TOTAL NEW: $total_new\n"; ?>