Results from the most recent live auction are here .
17 members in the live chat room. Join Chat !
02-13-2007, 07:04 AM
· #1 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
PHP: Grab Search Engine Results
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/ PHP Code:
<?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 by Matthew. : 02-13-2007 at 08:23 AM .
02-14-2007, 10:13 AM
· #3 Senior Member
Name: Martin
Location: Montevideo, Uruguay
Join Date: Jul 2006
Posts: 1,403
NP$: 323.00 (
Donate )
Great one.
You're always sharing great scripts...
Quote: We're glad that you're fond of this member, but please give some rep points to some other members before giving it to Matthew. again.
02-14-2007, 11:27 AM
· #4 DNOA Member
Name: Joćo Fernandes Silva
Location: Portugal
Join Date: Oct 2005
Posts: 693
NP$: 14.95 (
Donate )
thanks very much
__________________
J oćo F ernandes S ilva Your Proxy Host - Currently not acepting new customers - for custom packages contact me
02-14-2007, 12:17 PM
· #5 NamePros Regular
Join Date: Apr 2006
Posts: 232
NP$: 2110.00 (
Donate )
Very nice and simple well done
__________________ Chimps.ca - Swans.ca - Snails.ca
02-14-2007, 06:51 PM
· #6 NamePros Regular
Name: Pete
Location: U.S.A.
Join Date: Jul 2005
Posts: 648
NP$: 67.00 (
Donate )
Great Job on this. I am glad that someone made this.
-CP
__________________
Your Link Here 10np$ a month Please PM me if you want theses spaces
' '
' '
ProTechGFX.com
02-16-2007, 01:33 PM
· #7 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
Just glad it came in handy to someone
Matt
02-16-2007, 01:47 PM
· #8 Formally Mikor.
Name: Michael Walker
Location: East Yorkshire, England
Join Date: Aug 2005
Posts: 2,440
NP$: 97.25 (
Donate )
Thanks, thats quite useful.
02-16-2007, 01:54 PM
· #9 Join Date: Jul 2006
Posts: 3,292
NP$: 215.85 (
Donate )
Nice simple code. Thanks.
__________________
LLLL.coms: ALL 2 Premium Letters + U + K
02-16-2007, 02:12 PM
· #10 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
02-16-2007, 02:15 PM
· #11 Formally Mikor.
Name: Michael Walker
Location: East Yorkshire, England
Join Date: Aug 2005
Posts: 2,440
NP$: 97.25 (
Donate )
I am surprised how few results there are for 'google' on msn.
02-16-2007, 02:19 PM
· #12 Stud Sausage
Location: England
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (
Donate )
What's even more intereting is that if we go to msn search manually and search for google, it comes up with a lot more results.
Bug
I will look into later, i must do some work for now however it seems fine for anything other than the word "google". (which is stupid as it should make no difference...)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off