Re: make use of search results from public search engines

From: Date: Mon, 14 Aug 2000 21:26:19 +0000
Subject: Re: make use of search results from public search engines
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-11687@lists.php.net to get a copy of this message
Koo writes: > By specifying the following URL, you can use Google to search some > specific websites, "www.php.net" in this case, by providing certain > keywords, "zend optimizer" in this case. > > http://www.google.com/search?q=zend+optimizer+site:www.php.net > > Now, I'd like to buildup a search interface (a text box) for user > to do the above search and have the results displayed on MY WEBSITE. > > How do I do that? > > I tried the following script, but it doesn't work. :-( > [snip] > > Thanks. > Koo You're going to too much trouble: you can get the information easier using something like this (note that this simple example dosen't even try to cope with the next/last page thing, although it should be fairly easy to do this). But I'm not sure that Google would be too happy about you using this, since they sell this service separately. This is only meant to demonstrate one way of doing this sort of thing. :) <?php error_reporting(E_ALL); $fp = fopen("http://www.google.com/search?q=zend+optimizer+site:www.php.net", 'r'); $msg = ''; $count = 0; while (!feof($fp)) { $tmp = fgets($fp, 4096); if (preg_match('/^<p><A HREF=/', $tmp)) { $msg .= $tmp; $count++; } } fclose($fp); echo "<h2>Search found $count hits:</h2>$msg\n"; ?> Cheers, Torben -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.general (#11687) next »