- Impact
- 89
Have you ever needed to find the amount of results for certain keywords from all three major search engines? (Google, MSN, Yahoo)*?
Well, with this you can find all those figures within one page!
* If you want a new search engine added please reply here with the url.
Demo:
http://mattjewell.com/namepros/seresults/
Enjoy!
Matt
Well, with this you can find all those figures within one page!
* If you want a new search engine added please reply here with the url.
Demo:
http://mattjewell.com/namepros/seresults/
PHP:
<?php
/*
Code written by Matt Jewell (http://mattjewell.com) for http://namepros.com
Namepros username: "Matthew." (id #45276 http://www.namepros.com/member.php?u=45276)
Feel free to redistribute but please link back to both mattjewell.com and the namepros topic.
Link backs are NOT required for personal or comercial use however are always appreciated.
*/
if(strlen($_GET['keywords']) > 0 && isset($_GET['search']))
{
echo '<h1>Searching for <em>' . stripslashes($_GET['keywords']) . '</em></h1>';
ob_start();
$keywords = str_replace(' ', '+', stripslashes($_GET['keywords']));
// provider name => (string pattern, search url)
$engines = array('MSN' => array('Page [0-9] of ([^\.]+) results', 'http://search.live.com/results.aspx?q='),
'Google' => array('Results <b>[0-9]+<\/b> - <b>[0-9]+<\/b> of about <b>([^\.]+)<\/b> for', 'http://google.com/search?q='),
'Yahoo' => array('[0-9]+ - [0-9]+ of about ([^\.]+) for', 'http://search.yahoo.com/search?p=')
);
foreach($engines as $key => $value)
{
if(preg_match("/{$value[0]}/i", file_get_contents($value[1] . $keywords), $matches))
{
echo "<strong>$key</strong>: {$matches[1]} results found<br />";
}
else
{
echo "<strong>$key</strong>: No Matches";
}
ob_flush();
flush();
}
}
else
{
if(!isset($_GET['search']))
{
?>
<form action="<? echo $_SERVER['PHP_SELF'] ?>" method="get">
Keywords: <input type="text" name="keywords" value="" /><br />
<input type="submit" name="search" value="Search" />
</form>
<?php
}
else
{
echo 'You did not enter any keywords';
}
}
?>
Enjoy!
Matt
Last edited:







