Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Other Search Engines

Quote Reply
Other Search Engines
I have read the following Thread:

http://www.gossamer-threads.com/...ew=&sb=&vc=1

And it seems close to what I want to do with the search.cgi but not exactly....

What I am attempting to do is allow people to select a "mode" to search (either my directory or the Web). If they choose "web" for the mode, then they will be redirected to another search engine result page.

Here is what I have done so far:

1) Edited sub main to look like the following:

Code:

sub main {
# ---------------------------------------------------
# Determine what to do.
#
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
print $in->header();

if ($in->param('query')) {
&search ($in, $dynamic);
}
elsif ($in->param('mode') eq 'attech') {
&attech ($in, $dynamic);
}
elsif ($in->param('mode') eq 'wwwvl') {
&wwwvl ($in, $dynamic);
}
elsif ($in->param('mode') eq 'web') {
&websearch ($in, $dynamic);
}
elsif ($in->param('mode') eq 'books') {
&books ($in, $dynamic);
}
else {
my $title_linked = &build_linked_cgi_title ("Search Site");
&site_html_search_form ( { query => '', title_linked => $title_linked}, $dynamic );
}
}


2) Then I added the subs for the other search engine. Here is an example:

Code:

sub books {
#---------------------------------------------------------
# Searches Amazon.com

my ($in, $dynamic) = @_;
my $engine = "http://vlib.anthrotech.com/bin/amazon.cgi?keyword=";
my $redir = $in->param('query');
# Convert spaces to plus's
$redir =~ s/\ /+/g;
print $in->redirect ("$engine$redir&whichamazon=http://www.amazon.com&mymode=first&tag=anthrotechbookst");
}


This does not work...what happens is that a new result page appears adding mode=books to the query string. It does not redirect to the other search engines.

Any thoughts?

Thanks in advance (TIA).

Regards,

Eliot

Quote Reply
Re: Other Search Engines In reply to
I'm having a bit of trouble following exactly what you are doing.

You have $engine defined by:

http://vlib.anthrotech.com/bin/amazon.cgi?keyword=";

What does "amazon.cgi" do?

Is that the re-director?

If not,that may be the problem, because that is the URL you are actually redirecting to.

If that is the re-director,then the problem is probably in the amazon.cgi,not the code you just showed.

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Other Search Engines In reply to
Thanks for your response, pugdog. I appreciate it.

Although I don't think I have explained the problem clearly enough. What I am attempting to do is that if people select a "mode", it will take the query from my search form and put it into the query string of another search engine and redirect to that search engine's result page.

Does this make it clearer?

To see an example using Links 2.0, check out the following:

You will notice that when you click on the above link, you are redirected to my main site search engine. This is what I am attempting to do with Links SQL.

The codes I am using in Links 2.0 are the following:

Code:

($in{'mode'} eq "both") and &both;
($in{'mode'} eq "web") and &websearch ();
($in{'mode'} eq "wwwvl") and &wwwvl ();
($in{'mode'} eq "attech") and &attech ();
($in{'mode'} eq "books") and &books ();


in the sub main routine in search.cgi.

Then, for example, here is the attech subroutine:

Code:

sub attech {
#---------------------------------------------------------
# Searches the WWWVL sites

$engine = "http://www.anthrotech.com/cgibin/search/search.cgi?rg=all&ft=std&mh=10&cs=1&tms=";
$redir = $in{'query'};
# Convert spaces to plus's
$redir =~ s/\ /+/g;
if ($numhits == 0) {
print "Location: $engine$redir\n\n" ;
}

}


Hope this is clearer.

Regards,

Eliot

Quote Reply
Re: Other Search Engines In reply to
Your referrer check doesn't allow running the script from here -- so that is working. :)

It seems what you are trying to do is create a URL string, then redirect the users browser to that URL? That should be all it takes. That's all that is used in jump.cgi and all I've used in some other small programs.

What if you print (Location: ...) instead of using the $in->redirect ?

It may be 6 of one half dozen of the other.

I gather the 'amazon.cgi' is the maxxcom script, so you are redirecting to a redirector. I don't know if that is what is making the difference?? I don't have that script running any more to check.

I've looked through my scripts and I'm not sending anyone to a .cgi program, only sites/pages so I can't play with it at my end.

I'm looking at your subroutine, and I'm still missing something.

Code:
sub attech {
#---------------------------------------------------------
# Searches the WWWVL sites

$engine = "http://www.anthrotech.com/cgibin/search/search.cgi?rg=all&ft=std&mh=10&cs=1&tms=";
$redir = $in{'query'};
# Convert spaces to plus's
$redir =~ s/\ /+/g;
if ($numhits == 0) {
print "Location: $engine$redir\n\n" ;
}

}
When is "$numhits" == 0 ?? It looks like this is a default search, but that it already has run a search by the time it gets there in order to know how many hits it has.



http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/

Quote Reply
Re: Other Search Engines In reply to
Thanks for your input...print "Location:" does not work.

Anyway...I will play around with it and see what I can come up with...I thought this would be a simple question to address...Oh well.

Wink

Regards,

Eliot Lee

Quote Reply
Re: Other Search Engines In reply to
Nothing's ever simple, but as I said, it works for "jump.cgi" to redirect to the external URL, so it must be something in the code you are missing. Take a step back, and follow the code through step by step. In the "old days" that was the only way we could debug stuff. One line at a time, and compiles were expensive and hard to get, so you wanted to make each one count.

Today, it's easier to make a change, compile/run, and see if it works, looking for the error messages (error messages?? What error messages?? <G>).

Good luck:) And do post the answer, since I'm curious (and I'm sure I'll hit the same problem next week <G>).

http://www.postcards.com
FAQ: http://www.postcards.com/FAQ/LinkSQL/