NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page PHP: Grab Search Engine Results

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 02-13-2007, 07:04 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,565
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship

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']) > && 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='),
????: NamePros.com http://www.namepros.com/code/293724-php-grab-search-engine-results.html
                     
'Yahoo'    => array('[0-9]+ - [0-9]+ of about ([^\.]+) for''http://search.yahoo.com/search?p=')
                     );
            
????: NamePros.com http://www.namepros.com/showthread.php?t=293724
    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.
Matthew. is offline  
Old 02-13-2007, 07:12 AM   #2 (permalink)
NamePros Member
Join Date: Dec 2006
Posts: 138
Stitch is on a distinguished road
 



Nice one Matt
Stitch is offline  
Old 02-14-2007, 10:13 AM   #3 (permalink)
Senior Member
 
mtorregiani's Avatar
Join Date: Jul 2006
Location: Montevideo, Uruguay
Posts: 1,601
mtorregiani is a splendid one to beholdmtorregiani is a splendid one to beholdmtorregiani is a splendid one to beholdmtorregiani is a splendid one to beholdmtorregiani is a splendid one to beholdmtorregiani is a splendid one to beholdmtorregiani is a splendid one to behold
 


Cancer Survivorship
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.
mtorregiani is offline  
Old 02-14-2007, 11:27 AM   #4 (permalink)
JFS
NamePros Regular
 
JFS's Avatar
Join Date: Oct 2005
Location: Portugal
Posts: 886
JFS has much to be proud ofJFS has much to be proud ofJFS has much to be proud ofJFS has much to be proud ofJFS has much to be proud ofJFS has much to be proud ofJFS has much to be proud ofJFS has much to be proud ofJFS has much to be proud of
 



thanks very much
__________________
Joćo Fernandes Silva
Free Resources - Image Hosting - Allergy Info
Hosting - NP-Hosting.com - in beta, accepting orders
JFS is offline  
Old 02-14-2007, 12:17 PM   #5 (permalink)
NamePros Regular
 
baxter's Avatar
Join Date: Apr 2006
Posts: 360
baxter is just really nicebaxter is just really nicebaxter is just really nicebaxter is just really nice
 


Ethan Allen Fund Save The Children
Very nice and simple well done
__________________
Canadian Domain Registrar Ready.ca
baxter is offline  
Old 02-14-2007, 06:51 PM   #6 (permalink)
NamePros Regular
Join Date: Jul 2005
Location: U.S.A.
Posts: 655
Coolprogram has a spectacular aura aboutCoolprogram has a spectacular aura about
 



Great Job on this. I am glad that someone made this.
-CP
Coolprogram is offline  
Old 02-16-2007, 01:33 PM THREAD STARTER               #7 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,565
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
Just glad it came in handy to someone

Matt
Matthew. is offline  
Old 02-16-2007, 01:47 PM   #8 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




Thanks, thats quite useful.
Barrucadu is offline  
Old 02-16-2007, 01:54 PM   #9 (permalink)
 
kleszcz's Avatar
Join Date: Jul 2006
Posts: 4,609
kleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatness
 



Marrow Donor Program Multiple Sclerosis
Nice simple code. Thanks.
kleszcz is offline  
Old 02-16-2007, 02:12 PM THREAD STARTER               #10 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,565
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
No problem, something i found quite...amusing

http://mattjewell.com/namepros/seres...&search=Search
http://mattjewell.com/namepros/seres...&search=Search
Matthew. is offline  
Old 02-16-2007, 02:15 PM   #11 (permalink)
Senior Member
 
Barrucadu's Avatar
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,689
Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold
 




I am surprised how few results there are for 'google' on msn.
Barrucadu is offline  
Old 02-16-2007, 02:19 PM THREAD STARTER               #12 (permalink)
Senior Member
Join Date: Dec 2006
Location: England
Posts: 1,565
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
 


Adoption Breast Cancer Breast Cancer Cancer Survivorship
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...)
Matthew. is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 03:31 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger