- <?php
- function get_link_gg ($site) {
-
- $trois = substr($site, 0,3);
- $sept = substr($site, 0,7);
-
- if ($trois != 'www' ) {
- if ($sept != 'http://') {
- echo 'nom de domaine invalide';
- return false;
- break;
- }
- }
-
- if ($trois == 'www') {
- $site = 'http://'.$site;
- }
-
- //recup le ndd
- $dom = ereg_replace("(http://[^/]*/)(.*)", "\\1", $site);
- //echo 'domaine='.$dom;
-
-
- $req = 'http://www.google.com/search?q=site:'.$dom.'&hl=fr';
- //echo 'requette='.$req.'<br />';
-
- if ($src = @file_get_contents($req)) {
- } else {
- echo '<p style="background-color: red; color:white; padding: 0 0 0 10px; font-weight: bold;">404 - URL introuvable</p>';
- return false;
- }
-
- /*
- echo '<textarea rows="20" cols="50" style="width:700px;">';
- echo htmlentities($src);
- echo 'xfgdxgf';
- echo '</textarea>';
- */
-
- preg_match_all('%[\s]*sur un total d\'environ[\s]*\<b\>(([0-9 ]*)*)\</b\>[\s]*%si', $src, $out);
-
- /*
- echo '<pre>';
- print_r($out);
- echo '</pre>';
- */
-
- if (isset ($out[1][0])) {
- return $out[1][0];
- } else {
- echo 'erreur lors de la reception des résultats';
- return false;
- }
- }
-
- echo get_link_gg ('http://www.google.fr/');
- ?>
<?php
function get_link_gg ($site) {
$trois = substr($site, 0,3);
$sept = substr($site, 0,7);
if ($trois != 'www' ) {
if ($sept != 'http://') {
echo 'nom de domaine invalide';
return false;
break;
}
}
if ($trois == 'www') {
$site = 'http://'.$site;
}
//recup le ndd
$dom = ereg_replace("(http://[^/]*/)(.*)", "\\1", $site);
//echo 'domaine='.$dom;
$req = 'http://www.google.com/search?q=site:'.$dom.'&hl=fr';
//echo 'requette='.$req.'<br />';
if ($src = @file_get_contents($req)) {
} else {
echo '<p style="background-color: red; color:white; padding: 0 0 0 10px; font-weight: bold;">404 - URL introuvable</p>';
return false;
}
/*
echo '<textarea rows="20" cols="50" style="width:700px;">';
echo htmlentities($src);
echo 'xfgdxgf';
echo '</textarea>';
*/
preg_match_all('%[\s]*sur un total d\'environ[\s]*\<b\>(([0-9 ]*)*)\</b\>[\s]*%si', $src, $out);
/*
echo '<pre>';
print_r($out);
echo '</pre>';
*/
if (isset ($out[1][0])) {
return $out[1][0];
} else {
echo 'erreur lors de la reception des résultats';
return false;
}
}
echo get_link_gg ('http://www.google.fr/');
?>