make use of search results from public search engines
| From: | Koo | Date: | Mon, 14 Aug 2000 20:45:07 +0000 |
| Subject: | make use of search results from public search engines | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-11681@lists.php.net to get a copy of this message | ||
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. :-(
<?
function PostToHost($host, $path, $referer, $data_to_send)
{
$fp = fsockopen($host,80);
fputs($fp, "GET $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Referer: $referer\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data_to_send)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data_to_send);
while(!feof($fp))
{
$msg .= fgets($fp, 128);
}
return $msg;
fclose($fp);
}
PostToHost("www.google.com","/search","http://www.google.com","q=zend+optimizer+site:www.php.net");
echo $msg;
?>
Thanks.
Koo