Code :
- <?php
- function get_CodeHTML($URL)
- {
- $file=fopen($URL,"r" );
- if(!$file)
- {
- echo "<p>Impossible d'ouvrir le fichier</p>.\n";
- exit;
- }
- while(!feof($file))
- {
- $line .= fgets($file,1024);
- }
- fclose($file);
- // nettoyage du code
- // 1. retirer les balise HTML
- $line = strip_tags($line);
- // 2.supprimer les retour à la ligne
- $line = str_replace("\n","",$line);
- return $line;
- }
- function getStringBetween ($chaine,$debut,$fin)
- {
- preg_match("/".$debut.".*".$fin."/U", $chaine, $retour);
- $mot = $retour[0];
- $mot = ereg_replace ($debut,"",$mot);
- $mot = ereg_replace ($fin,"",$mot);
- return $mot;
- }
- $URL = "http://setiathome.ssl.berkeley.edu/cgi-bin/cgi?email=stoclin@ifrance.com&cmd=user_stats_new";
- $codeHTML = get_CodeHTML($URL);
- echo getStringBetween ($codeHTML,"Results Received","Total CPU" );
- ?>
|