PDA

View Full Version : single search interface


thor
10-19-2001, 02:49 AM
Here's something I'd like to do, and have seen it done on one or two sites. Have a search box, but allow the user to specify searching my site (using an existing cgi based search), searching using one of the major search engines, or using a specialty engine.

I'd like to have a drop down box to allow such selection. Anyone know what would be involved here?

I'm guessing here that it would require a cgi script to call the appropriate engine that the user chooses. Does that makes sense? Is such a thing available?

colulus
10-26-2001, 05:05 PM
How to do it. Three html pages, one for the frame declarations, one for the navigation frame, and one to be the default page for filling in the results frame. The nav frame is a form, and have the form call your search script. A brief start script:
_______________
#!usr/bin/perl -w
use strict;
use CGI qw/:standard/;

my $url;
my $qtp = param('qtype');
my $qry = param('query');

if ($qtp eq 'Newsgroups') {
$url = 'http://www.deja.com/dnquery.xp?QRY=' . $qry . '&ST=MS&svcclass=dnserver&DBS=1';
print redirect($url);
}

elsif ($qtp eq 'oingo') {
$url = 'http://search.oingo.com/find.dll?s=' . $qry;
print redirect($url);
}
_______________
etc..
The 'Newsgroups' and 'oingo' options must of course be selectable options in your navigation form. You can easily figure out what funny code to put in the url by using the respective search engine and reading the url generated.