Created
August 10, 2017 07:17
-
-
Save titomus/a219b0d7519c2f704a210b012e925716 to your computer and use it in GitHub Desktop.
Function pour récupérer le nombre de résultats Google (FR)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_search_num($keyword){ | |
$url = sprintf('http://www.google.fr/search?pws=0&hl=fr&q=%s', $keyword); | |
$data = file_get_contents($url); | |
$pattern = sprintf( | |
'/%s(.*?)%s/', | |
preg_quote('Environ'), | |
preg_quote('résultats') | |
); | |
preg_match_all($pattern, utf8_encode($data), $matches); | |
return trim($matches[1][0]); | |
} | |
// utilisation | |
echo get_search_num('seo'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment